-
Type: Bug
-
Resolution: Done
-
Priority: Critical - P2
-
None
-
Affects Version/s: 1.3.1
-
Component/s: libbson
-
Labels:None
copy_to_excluding(src, dst, key, ...) cannot be used because of BSON_ASSERT(dst) demands that bson_t *dst = bson_new()
which will then create a memory leak since it malloc a second bson_t.
ie.
bson_t *dst;
copy_to_excluding(src, dst, key, ...) // prints error message
...
bson_destroy(dst);
bson_t *dst = bson_new()
copy_to_excluding(src, dst, key, ...) // no error message but memory leak
...
bson_destroy(dst);
copy_to_excluding_noinit(src, dst, key, ...) is the only possible non-leaking alternative as it doesnt malloc the second bson_t.