[CDRIVER-2541] Unlikely leak converting corrupt BSON to JSON Created: 08/Mar/18  Updated: 28/Oct/23  Resolved: 12/Apr/18

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

Type: Bug Priority: Trivial - P5
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


 Description   

Leak of memory or pointers to system resources

Defect 101866 (STATIC_C)
Checker RESOURCE_LEAK (subcategory none)
File: /src/bson/bson.c
Function _bson_as_json_visit_document
/src/bson/bson.c, line: 3039
Assigning: "child_state.str" = storage returned from "bson_string_new("{ ")".

          child_state.str = bson_string_new ("{ ");

/src/bson/bson.c, line: 3043
Variable "child_state" going out of scope leaks the storage "child_state.str" points to.

             return true;



 Comments   
Comment by Githook User [ 12/Apr/18 ]

Author:

{'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis'}

Message: CDRIVER-2541 leak if encoding bad BSON to JSON

Early exit from _bson_as_json_visit_array / _bson_as_json_visit_document
didn't free the JSON string that was under construction.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/992baab9fd43a31db2e47d98eab2c30c32ac27b1

Comment by A. Jesse Jiryu Davis [ 08/Mar/18 ]

Coverity opened this ticket in DRIVERS instead of CDRIVER due to misconfiguration.

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