Skip to content

Zend: Fix GH-25700 and GH-25706: Destructor sees the value being replaced by a hash update - #25804

Open
Roman3349 wants to merge 1 commit into
php:PHP-8.4from
Roman3349:fix/gh-25700-hash-update-order
Open

Roman3349 wants to merge 1 commit into
php:PHP-8.4from
Roman3349:fix/gh-25700-hash-update-order

Conversation

@Roman3349

Copy link
Copy Markdown
Contributor

When an existing value is replaced, _zend_hash_add_or_update_i() and its str and index variants destroy the old value before storing the new one, so a destructor running from it still finds the old value in the table. Store the new value first and destroy the old one afterwards, as zend_hash_del() already does. zend_hash_str_del_ind() now uses the same order as zend_hash_del_ind().

The auto-global callbacks also added the PG(http_globals) reference only after zend_hash_update(), so a destructor that unset or replaced $_ENV or $_SERVER freed the new array. Add the reference first.

Fixes GH-25700
Fixes GH-25706

…troying old one in hash update

Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
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