File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed
Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change 1+ --TEST--
2+ Overwriting a typed property that is not yet a reference
3+ --FILE--
4+ <?php
5+
6+ class Test {
7+ public ?Test $ prop ;
8+ }
9+ $ s = <<<'STR'
10+ O:4:"Test":2:{s:4:"prop";N;s:4:"prop";O:4:"Test":1:{s:4:"prop";R:2;}}
11+ STR;
12+ var_dump (unserialize ($ s ));
13+
14+ ?>
15+ --EXPECT--
16+ object(Test)#1 (1) {
17+ ["prop"]=>
18+ &object(Test)#2 (1) {
19+ ["prop"]=>
20+ *RECURSION*
21+ }
22+ }
Original file line number Diff line number Diff line change @@ -556,9 +556,17 @@ string_key:
556556 /* This is a property with a declaration */
557557 old_data = Z_INDIRECT_P (old_data);
558558 info = zend_get_typed_property_info_for_slot (obj, old_data);
559- if (info && Z_ISREF_P (old_data)) {
560- /* If the value is overwritten, remove old type source from ref. */
561- ZEND_REF_DEL_TYPE_SOURCE (Z_REF_P (old_data), info);
559+ if (info) {
560+ if (Z_ISREF_P (old_data)) {
561+ /* If the value is overwritten, remove old type source from ref. */
562+ ZEND_REF_DEL_TYPE_SOURCE (Z_REF_P (old_data), info);
563+ }
564+
565+ if ((*var_hash)->ref_props ) {
566+ /* Remove old entry from ref_props table, if it exists. */
567+ zend_hash_index_del (
568+ (*var_hash)->ref_props , (zend_uintptr_t ) old_data);
569+ }
562570 }
563571 var_push_dtor (var_hash, old_data);
564572 Z_TRY_DELREF_P (old_data);
You can’t perform that action at this time.
0 commit comments