mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix use-after-free in SplObjectStorage::setInfo()
This commit is contained in:
@@ -739,8 +739,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 */
|
||||
|
||||
25
ext/spl/tests/gh16479.phpt
Normal file
25
ext/spl/tests/gh16479.phpt
Normal 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) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user