|
Prior to CDRIVER-1381 the reply bson_t was not initialized if mongoc_collection_find_and_modify() returned false. To prevent badness client code needed to effectively do something like:
|
old way
|
bool ok;
|
bson_t reply;
|
|
ok = mongoc_collection_find_and_modify (collection, query, NULL, update, NULL, false, false, true, &reply, &error);
|
|
if(ok) {
|
bson_destroy(&reply);
|
}
|
Now the reply bson_t is always initialized regardless of the return value of mongoc_collection_find_and_modify(). Based on the comment for the change it does not seem like this was intended. Is this new behavior a bug? Should client code like the code above? Or like the code below?
|
new way?
|
bool ok;
|
bson_t reply;
|
|
ok = mongoc_collection_find_and_modify (collection, query, NULL, update, NULL, false, false, true, &reply, &error);
|
|
bson_destroy(&reply);
|
|