Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit fc86aa2

Browse files
committed
Free bson_reader_t before throwing on bson_reader_read() errors
1 parent 589740e commit fc86aa2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/MongoDB/BSON/functions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,12 @@ Variant HHVM_FUNCTION(MongoDBBsonToJson, const String &data)
111111

112112
bson_free(str);
113113
} else {
114+
bson_reader_destroy(reader);
114115
throw MongoDriver::Utils::throwUnexpectedValueException("Could not read document from BSON reader");
115-
return Variant();
116116
}
117117

118118
if (bson_reader_read(reader, &eof) || !eof) {
119+
bson_reader_destroy(reader);
119120
throw MongoDriver::Utils::throwUnexpectedValueException("Reading document did not exhaust input buffer");
120121
}
121122

0 commit comments

Comments
 (0)