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

HHVM-183: toJSON() should throw if bson_as_json() fails #72

Merged
merged 2 commits into from
Mar 8, 2016
Merged

HHVM-183: toJSON() should throw if bson_as_json() fails #72

merged 2 commits into from
Mar 8, 2016

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Mar 2, 2016

@@ -99,6 +99,12 @@ Variant HHVM_FUNCTION(MongoDBBsonToJson, const String &data)

str = bson_as_json(b, &str_len);

if (!str) {
throw MongoDriver::Utils::throwUnexpectedValueException("Could not convert BSON document to JSON");
bson_reader_destroy(reader);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't work. The throw is a C++ exception which immediately returns from the function. The destroy should be first, and the return Variant() can be removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, of course :)

@jmikola
Copy link
Member Author

jmikola commented Mar 4, 2016

Updated to move freeing before the throw statements.

@derickr derickr merged commit fc86aa2 into mongodb:master Mar 8, 2016
derickr added a commit that referenced this pull request Mar 8, 2016
@jmikola jmikola deleted the hhvm-183 branch March 15, 2016 18:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants