File tree 3 files changed +29
-1
lines changed
3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ PHP NEWS
70
70
. Fixed bug GH-16337 (Use-after-free in SplHeap). (nielsdos)
71
71
. Fixed bug GH-16464 (Use-after-free in SplDoublyLinkedList::offsetSet()).
72
72
(ilutov)
73
+ . Fixed bug GH-16479 (Use-after-free in SplObjectStorage::setInfo()). (ilutov)
73
74
74
75
- Standard:
75
76
. Fixed bug GH-16293 (Failed assertion when throwing in assert() callback with
Original file line number Diff line number Diff line change @@ -746,8 +746,10 @@ PHP_METHOD(SplObjectStorage, setInfo)
746
746
if ((element = zend_hash_get_current_data_ptr_ex (& intern -> storage , & intern -> pos )) == NULL ) {
747
747
RETURN_NULL ();
748
748
}
749
- zval_ptr_dtor (& element -> inf );
749
+ zval garbage ;
750
+ ZVAL_COPY_VALUE (& garbage , & element -> inf );
750
751
ZVAL_COPY (& element -> inf , inf );
752
+ zval_ptr_dtor (& garbage );
751
753
} /* }}} */
752
754
753
755
/* {{{ Moves position forward */
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-16479: Use-after-free in SplObjectStorage::setInfo()
3
+ --FILE--
4
+ <?php
5
+
6
+ class C {
7
+ function __destruct () {
8
+ global $ store ;
9
+ $ store ->removeAll ($ store );
10
+ }
11
+ }
12
+
13
+ $ o = new stdClass ;
14
+ $ store = new SplObjectStorage ;
15
+ $ store [$ o ] = new C ;
16
+ $ store ->setInfo (1 );
17
+ var_dump ($ store );
18
+
19
+ ?>
20
+ --EXPECT--
21
+ object(SplObjectStorage)#2 (1) {
22
+ ["storage":"SplObjectStorage":private]=>
23
+ array(0) {
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments