File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -635,7 +635,7 @@ PHP_METHOD(SplFixedArray, __unserialize)
635635 intern -> array .size = 0 ;
636636 ZEND_HASH_FOREACH_STR_KEY_VAL (data , key , elem ) {
637637 if (key == NULL ) {
638- ZVAL_COPY (& intern -> array .elements [intern -> array .size ], elem );
638+ ZVAL_COPY_DEREF (& intern -> array .elements [intern -> array .size ], elem );
639639 intern -> array .size ++ ;
640640 } else {
641641 Z_TRY_ADDREF_P (elem );
@@ -822,7 +822,7 @@ PHP_METHOD(SplFixedArray, offsetGet)
822822 value = spl_fixedarray_object_read_dimension_helper (intern , zindex );
823823
824824 if (value ) {
825- RETURN_COPY_DEREF (value );
825+ RETURN_COPY (value );
826826 } else {
827827 RETURN_NULL ();
828828 }
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-20614 (SplFixedArray incorrectly handles references in deserialization)
3+ --FILE--
4+ <?php
5+
6+ $ fa = new SplFixedArray (0 );
7+ $ nr = 1 ;
8+ $ array = [&$ nr ];
9+ $ fa ->__unserialize ($ array );
10+ var_dump ($ fa );
11+ unset($ fa [0 ]);
12+ var_dump ($ fa );
13+
14+ ?>
15+ --EXPECT--
16+ object(SplFixedArray)#1 (1) {
17+ [0]=>
18+ int(1)
19+ }
20+ object(SplFixedArray)#1 (1) {
21+ [0]=>
22+ NULL
23+ }
You can’t perform that action at this time.
0 commit comments