Skip to content

ext/standard: Finish hash fill before RETURN_OOM() in str_split() - #25972

Open
iliaal wants to merge 1 commit into
php:PHP-8.6from
iliaal:fix/str-split-oom-hash-fill-86
Open

iliaal wants to merge 1 commit into
php:PHP-8.6from
iliaal:fix/str-split-oom-hash-fill-86

Conversation

@iliaal

@iliaal iliaal commented Nov 30, 2026

Copy link
Copy Markdown
Member

When str_split() hits the memory limit partway through, it returns via RETURN_OOM() inside ZEND_HASH_FILL_PACKED() without calling ZEND_HASH_FILL_FINISH(), so the result array's element count stays 0 and the segment strings already written are never released by its destructor. Finish the fill before returning, as explode() does. Introduced in d6373df.

str_split() returned via RETURN_OOM() inside ZEND_HASH_FILL_PACKED()
without calling ZEND_HASH_FILL_FINISH(). Because nNumUsed and
nNumOfElements are only flushed when the fill block finishes, every
segment string already written to arPacked leaked when return_value was
destroyed on OOM. Call ZEND_HASH_FILL_FINISH() before RETURN_OOM().
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