mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix use after free during shutdown destruction
This commit is contained in:
commit
bb6263af60
3 changed files with 30 additions and 1 deletions
3
NEWS
3
NEWS
|
@ -2,6 +2,9 @@ PHP NEWS
|
||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
?? ??? ????, PHP 8.4.10
|
?? ??? ????, PHP 8.4.10
|
||||||
|
|
||||||
|
- Core:
|
||||||
|
. Fixed bug GH-18833 (Use after free with weakmaps dependent on destruction
|
||||||
|
order). (Daniil Gentili)
|
||||||
|
|
||||||
03 Jul 2025, PHP 8.4.9
|
03 Jul 2025, PHP 8.4.9
|
||||||
|
|
||||||
|
|
24
Zend/tests/gh18833.phpt
Normal file
24
Zend/tests/gh18833.phpt
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
--TEST--
|
||||||
|
GH-18833 (Use after free with weakmaps dependent on destruction order)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class a {
|
||||||
|
public static WeakMap $map;
|
||||||
|
public static Generator $storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
a::$map = new WeakMap;
|
||||||
|
|
||||||
|
$closure = function () {
|
||||||
|
$obj = new a;
|
||||||
|
a::$map[$obj] = true;
|
||||||
|
yield $obj;
|
||||||
|
};
|
||||||
|
a::$storage = $closure();
|
||||||
|
a::$storage->current();
|
||||||
|
|
||||||
|
echo "ok\n";
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
ok
|
|
@ -100,7 +100,9 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_free_object_storage(zend_objects_
|
||||||
if (IS_OBJ_VALID(obj)) {
|
if (IS_OBJ_VALID(obj)) {
|
||||||
if (!(OBJ_FLAGS(obj) & IS_OBJ_FREE_CALLED)) {
|
if (!(OBJ_FLAGS(obj) & IS_OBJ_FREE_CALLED)) {
|
||||||
GC_ADD_FLAGS(obj, IS_OBJ_FREE_CALLED);
|
GC_ADD_FLAGS(obj, IS_OBJ_FREE_CALLED);
|
||||||
if (obj->handlers->free_obj != zend_object_std_dtor) {
|
if (obj->handlers->free_obj != zend_object_std_dtor
|
||||||
|
|| (OBJ_FLAGS(obj) & IS_OBJ_WEAKLY_REFERENCED)
|
||||||
|
) {
|
||||||
GC_ADDREF(obj);
|
GC_ADDREF(obj);
|
||||||
obj->handlers->free_obj(obj);
|
obj->handlers->free_obj(obj);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue