[php-src] PR #22467: Fix use-after-free in Collator::sort() with a mutating comparator
| From: | iliaal | Date: | Fri, 26 Jun 2026 13:11:56 +0000 |
| Subject: | [php-src] PR #22467: Fix use-after-free in Collator::sort() with a mutating comparator | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36667@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22467
Author: iliaal
Collator::sort() and Collator::asort() with COLLATOR_SORT_REGULAR use each object element's
__toString() as the comparison key. If that __toString() appends to the array being sorted
(reachable through a reference), the array's backing storage is reallocated while
zend_hash_sort() still holds pointers into it, a use-after-free. usort() already avoids this by
duplicating the array before sorting; Collator now does the same.