[MONGOCRYPT-555] _finalize is missing call to bson_destroy in an error case Created: 09/Mar/23  Updated: 27/Apr/23  Resolved: 27/Apr/23

Status: Closed
Project: Libmongocrypt
Component/s: None
Affects Version/s: None
Fix Version/s: 1.8.0

Type: Bug Priority: Unknown
Reporter: Zachary Espiritu Assignee: Kyle Kloberdanz
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Binding Changes: Not Needed

 Description   

In _finalize in mongocrypt-ctx-encrypt.c, the error case starting on line 2011 (in commit 2ec9c3) appears to be missing bson_destroy (&converted). This is because in the case where ectx->explicit is false on line 1985 and the bson_t converted is initialized on line 1996, if the call to _mongocrypt_buffer_to_bson fails on line 2009, _finalize returns without having destroyed the converted instance.



 Comments   
Comment by Githook User [ 26/Apr/23 ]

Author:

{'name': 'Kyle Kloberdanz', 'email': 'kyle.kloberdanz@mongodb.com', 'username': 'kkloberdanz'}

Message: Fix memory leak in _finalize (#630)

MONGOCRYPT-555

Missing a call to bson_destroy(&converted) after converted as initialized.
Branch: master
https://github.com/mongodb/libmongocrypt/commit/09bdceb5f7a17882e15f3a86f9090b6a558eee2f

Generated at Thu Feb 08 09:08:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.