Skip to content

ext/standard: Finish hash fill before RETURN_OOM() in array_map() - #25973

Open
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/array-map-oom-hash-fill
Open

iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/array-map-oom-hash-fill

Conversation

@iliaal

@iliaal iliaal commented Nov 30, 2026

Copy link
Copy Markdown
Member

In array_map() with a null callback and several arrays, RETURN_OOM() exits inside ZEND_HASH_FILL_PACKED() without calling ZEND_HASH_FILL_FINISH(), so the inner arrays already built are never released by the result array's destructor. Finish the fill before returning, as the callback error exit in the same block does. Introduced by the 9705fda merge.

In the multi-array null-callback branch of array_map(), RETURN_OOM() was
called inside ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) without
calling ZEND_HASH_FILL_FINISH(). Because nNumUsed and nNumOfElements are
only flushed when the fill block finishes, every inner array already
written to arPacked leaked when return_value was destroyed on OOM. Call
ZEND_HASH_FILL_FINISH() before returning, matching the callback error
exit in the same block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant