[CDRIVER-2485] Coverity analysis defect 103243: Resource leak Created: 01/Feb/18  Updated: 28/Oct/23  Resolved: 12/Feb/18

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: None
Fix Version/s: 1.10.0

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Post-3.6 cleanup

 Description   

Leak of memory or pointers to system resources

Defect 103243 (STATIC_C)
Checker RESOURCE_LEAK (subcategory none)
File: /src/mongoc/mongoc-cursor.c
Function _mongoc_cursor_parse_opts_for_op_query
/src/mongoc/mongoc-cursor.c, line: 1152
Assigning: "dollar_modifier" = storage returned from "bson_strdup_printf("$%s", key)".

             dollar_modifier = bson_strdup_printf ("$%s", key);

/src/mongoc/mongoc-cursor.c, line: 1154
Resource "dollar_modifier" is not freed or pointed-to in "bson_set_error".

                bson_set_error (&cursor->error,

/src/mongoc/mongoc-cursor.c, line: 1159
Variable "dollar_modifier" going out of scope leaks the storage it points to.

                return NULL;



 Comments   
Comment by A. Jesse Jiryu Davis [ 12/Feb/18 ]

https://github.com/mongodb/mongo-c-driver/commit/182f1b508dad512af8d59d0ed572f5097b0db5e7

Generated at Wed Feb 07 21:15:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.