[php-src] PR #21828: Fix GH-21824: Avoid unserialize context reuse during cleanup
| From: | prateekbhujel | Date: | Wed, 22 Apr 2026 06:56:45 +0000 |
| Subject: | [php-src] PR #21828: Fix GH-21824: Avoid unserialize context reuse during cleanup | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-35829@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/21828
Author: prateekbhujel
Fixes GH-21824.
The outer unserialize context stayed in
BG(unserialize) while
php_unserialize_data was being destroyed. If an object destructor re-entered
unserialize() from that cleanup path, the nested call could reuse the outer context
after its extra var entries had already been freed.
Clear the outer context before running var_destroy() for the outermost call, so
destructor reentry starts with a fresh unserialize context instead of the one currently being torn
down.
Tests:
- sapi/cli/php run-tests.php -q ext/standard/tests/serialize/gh21824.phpt
- sapi/cli/php run-tests.php -q ext/standard/tests/serialize