-
Type: Bug
-
Resolution: Done
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
-
Not Needed
In FLE2RangeFindDriverSpec_to_ciphertexts in mongocrypt-ctx-encrypt.c, a Valgrind memory leak can occur when the libbson BSON_MEMCHECK compile flag is set because:
- bson_t with_placholders is initialized on line 1730 (as of commit 2ec9c3) with BSON_INITIALIZER
- The function calls mc_FLE2RangeFindDriverSpec_to_placeholders on line 1768 and passes with_placholders as the out argument.
- mc_FLE2RangeFindDriverSpec_to_placeholders calls bson_init on out on line 508
One possible solution is to remove the extra call to bson_init within the mc_FLE2RangeFindDriverSpec_to_placeholders function. Note that there is a test case in test-mc-fle2-rfds.c that uses mc_FLE2RangeFindDriverSpec_to_placeholders and the out argument passed to that test function will need to be initialized if this change is made.
—
To reproduce the memory leak, use
mkdir cmake-build && cd cmake-build cmake ../ make valgrind --leak-check=full ./test-mongocrypt