Repository navigation
Zend: fix memory leak in array_map - #24138
Merged
Merged
Conversation
LamentXU123
approved these changes
Oct 5, 2026
LamentXU123
left a comment
Member
There was a problem hiding this comment.
This looks correct to me.
/cc @arnaud-lb
arnaud-lb
reviewed
Oct 9, 2026
arnaud-lb
left a comment
Member
There was a problem hiding this comment.
This looks correct, but I don't like that we are managing an invalid case. An alternative is to skip the optimization when we know that the array argument is not an array (return FAILURE). We can re-use the body of the if (!call_args) { block by moving it at the end of the function with a goto label.
Contributor
Author
|
@arnaud-lb I thought about this solution as well. I decided to do it this way, because I wanted to keep the fix surgical, but I agree suggested approach is much cleaner. I can implement these changes. |
adapik
force-pushed
the
fix-memory-leak-array-map
branch
from
October 9, 2026 14:42
9f728b9 to
4843455
Compare
arnaud-lb
added a commit
that referenced
this pull request
Oct 15, 2026
* PHP-8.6: Fix memory leak in array_map optimization (#24138)
Member
|
Thank you! |
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.
zend_compile_func_array_map()takes an extra reference on a constant array argument because it is used by bothZEND_TYPE_ASSERTandZEND_FE_RESET_R. For a non-interned string literal the refcount becomes 2, so the laterzval_make_interned_string()copies the string and leaks the original: