Skip to content

PHPC-531, PHPC-616: Fix segfault and improve error reporting for corrupt BSON #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 4, 2016

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Mar 2, 2016

These test cases are derived from PHPC-615.
/* Iteration stopped prematurely due to corruption or a failed visitor.
* While we free the reader, state->zchild should be left as-is, since
* the calling code may want to zval_ptr_dtor() it. */
phongo_throw_exception(PHONGO_ERROR_UNEXPECTED_VALUE TSRMLS_CC, "Could not convert BSON document to PHP");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the message is a bit clunky? PHP what? Perhaps, "to a PHP variable" would be better?

jmikola added 2 commits March 4, 2016 10:59
Freeing the current zval in the corrupt BSON visitor causes a segfault if done for the root document, since phongo_bson_to_zval_ex() expects the calling code to initialize and free that zval on success or error.

That said, we should free when encountering an error via the document or array visitors (i.e. nested context), which would have just been initialized.
@jmikola jmikola merged commit 3da1aa6 into mongodb:master Mar 4, 2016
jmikola added a commit that referenced this pull request Mar 4, 2016
@jmikola jmikola deleted the phpc-531 branch March 4, 2016 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants