datanoise / mongo.cr

Crystal binding for MongoDB C Driver
MIT License
97 stars 35 forks source link

bson: fix memory leaks when appending documents or arrays #58

Closed elbywan closed 2 years ago

elbywan commented 4 years ago

Issue

Calling append_document or append_array was leaking memory asLibBSON.bson_append_document_begin or LibBSON.bson_append_array_begin are not supposed to be called with an already allocated bson handler.

Fix

Replaced bson_append_document_begin + bson_append_document_end combo with a single bson_append_document call. Same fix for arrays.