Fix arg zval leak in extract_callback_user_func#56
Open
iliaal wants to merge 1 commit into
Open
Conversation
The callback ZVAL_STRINGL's the chunk into `arg` but only released it on the success path. Both early returns — when zend_fcall_info_init() fails and when zend_call_function() fails — returned without dtoring `arg`, leaking one zend_string per chunk. The init-failure path is reachable from userland by passing a non-callable as the extract callback. zend_fcall_info_argn() ZVAL_COPYs the argument into fci.params (its own ref), so the original `arg` always needs exactly one zval_ptr_dtor. Release it on every path; dtor `retval` only on success, where the engine has actually written it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
extract_callback_user_funcZVAL_STRINGL's each decoded chunk intoargbut only freed it on the success path. Both early returns leaked onezend_stringper chunk:zend_fcall_info_init()failure (reachable from userland by passing a non-callable as the callback) andzend_call_function()failure.zend_fcall_info_argn()takes its own reference viaZVAL_COPY, so the caller'sargalways needs exactly onezval_ptr_dtor.Release
argon every path; dtorretvalonly on the success path, where the engine has populated it.