File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 2
2
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3
3
?? ??? ????, PHP 8.3.24
4
4
5
+ - Core:
6
+ . Fixed bug GH-18833 (Use after free with weakmaps dependent on destruction
7
+ order). (Daniil Gentili)
5
8
6
9
03 Jul 2025, PHP 8.3.23
7
10
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-18833 (Use after free with weakmaps dependent on destruction order)
3
+ --FILE--
4
+ <?php
5
+
6
+ class a {
7
+ public static WeakMap $ map ;
8
+ public static Generator $ storage ;
9
+ }
10
+
11
+ a::$ map = new WeakMap ;
12
+
13
+ $ closure = function () {
14
+ $ obj = new a ;
15
+ a::$ map [$ obj ] = true ;
16
+ yield $ obj ;
17
+ };
18
+ a::$ storage = $ closure ();
19
+ a::$ storage ->current ();
20
+
21
+ echo "ok \n" ;
22
+ ?>
23
+ --EXPECT--
24
+ ok
Original file line number Diff line number Diff line change @@ -104,7 +104,9 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_free_object_storage(zend_objects_
104
104
if (IS_OBJ_VALID (obj )) {
105
105
if (!(OBJ_FLAGS (obj ) & IS_OBJ_FREE_CALLED )) {
106
106
GC_ADD_FLAGS (obj , IS_OBJ_FREE_CALLED );
107
- if (obj -> handlers -> free_obj != zend_object_std_dtor ) {
107
+ if (obj -> handlers -> free_obj != zend_object_std_dtor
108
+ || (OBJ_FLAGS (obj ) & IS_OBJ_WEAKLY_REFERENCED )
109
+ ) {
108
110
GC_ADDREF (obj );
109
111
obj -> handlers -> free_obj (obj );
110
112
}
You can’t perform that action at this time.
0 commit comments