[php-src] PR #25469: Fix use-after-free when an error handler replaces the ArrayObject backing store
| From: | nicolas-grekas | Date: | Sun, 15 Nov 2026 16:53:02 +0000 |
| Subject: | [php-src] PR #25469: Fix use-after-free when an error handler replaces the ArrayObject backing store | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40658@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25469
Author: nicolas-grekas
An error handler can replace the backing store of an ArrayObject in the middle of an offset access.
The table that was fetched before the error is then used after it's freed:
```php
$ao = new ArrayObject(['a' => 1]);
set_error_handler(function () use ($ao) {
$ao->exchangeArray([]);
});
$ao[1.5];
```
It's the same for
isset($ao[1.5]), for $ao->b .= 'x' on
a missing key with ARRAY_AS_PROPS, and for ArrayIterator::seek(1.5) when
the handler calls __construct().
This PR fetches the table after the code that can call the handler.