[CDRIVER-115] bson object should not be initialized in an assert—release mode code does not compile asserts Created: 24/Feb/12  Updated: 12/Apr/12  Resolved: 12/Apr/12

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 0.4
Fix Version/s: 0.5

Type: Bug Priority: Major - P3
Reporter: Matthew Proujansky Assignee: Kyle Banker
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Visual Studio 2005, Windows, release mode compilation



 Description   

In mongodb-mongo-c-driver-1380839, version 0.4, in the file gridfs.c, line 129 is:
assert( mongo_run_command( gfs->client, gfs->dbname, &command, &res ) == MONGO_OK );

When compiling this code in Visual Studio 2005 (and presumably other compilers), in debug mode the assert is compiled, but in release mode the assert is ignored.

Therefore, in release mode the bson object "res" is not initialized, and when "res" is used on line 141:
bson_find( &it, &res, "md5" );

the code will crash.

Initializing "res" should be done outside the assert.


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