1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix use-after-free in SplObjectStorage::setInfo()
This commit is contained in:
Ilija Tovilo
2024-10-17 18:21:31 +02:00
3 changed files with 29 additions and 1 deletions

1
NEWS
View File

@@ -76,6 +76,7 @@ PHP NEWS
. Fixed bug GH-16337 (Use-after-free in SplHeap). (nielsdos)
. Fixed bug GH-16464 (Use-after-free in SplDoublyLinkedList::offsetSet()).
(ilutov)
. Fixed bug GH-16479 (Use-after-free in SplObjectStorage::setInfo()). (ilutov)
- Standard:
. Fixed bug GH-16293 (Failed assertion when throwing in assert() callback with

View File

@@ -744,8 +744,10 @@ PHP_METHOD(SplObjectStorage, setInfo)
if ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) == NULL) {
RETURN_NULL();
}
zval_ptr_dtor(&element->inf);
zval garbage;
ZVAL_COPY_VALUE(&garbage, &element->inf);
ZVAL_COPY(&element->inf, inf);
zval_ptr_dtor(&garbage);
} /* }}} */
/* {{{ Moves position forward */

View File

@@ -0,0 +1,25 @@
--TEST--
GH-16479: Use-after-free in SplObjectStorage::setInfo()
--FILE--
<?php
class C {
function __destruct() {
global $store;
$store->removeAll($store);
}
}
$o = new stdClass;
$store = new SplObjectStorage;
$store[$o] = new C;
$store->setInfo(1);
var_dump($store);
?>
--EXPECT--
object(SplObjectStorage)#2 (1) {
["storage":"SplObjectStorage":private]=>
array(0) {
}
}