Commit 0bc6dc3
committed
deepclone_to_array: drop unsound refcount==1 pool-skip optimization
dc_copy_value had a fast path that skipped the object-pool lookup
when Z_REFCOUNT_P(src) == 1 and no __serialize, on the assumption
that refcount==1 objects are only visited once. That assumption
breaks when the object is reached via a SHARED parent array: the
parent's refcount is > 1, but the contained object's is 1, and the
parent is walked multiple times, so the object is visited twice.
On the second visit, the skip bypassed the pool lookup, fell through
to dc_process_object, and tripped zend_hash_index_add_new's assertion
(slot already occupied from the first visit).
Fix: always do the pool lookup. The save-one-hash-find per object is
not worth the soundness risk.
Found by libFuzzer (roundtrip harness + duplicated shared containers).1 parent 3e0bf4f commit 0bc6dc3
1 file changed
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1050 | 1050 | | |
1051 | 1051 | | |
1052 | 1052 | | |
1053 | | - | |
1054 | | - | |
1055 | | - | |
1056 | | - | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
1057 | 1058 | | |
1058 | 1059 | | |
1059 | 1060 | | |
| |||
0 commit comments