File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-20482: ZEND_ASSIGN_DIM survives a hash table rehash forced by the output handler during the undefined-variable warning
3+ --FILE--
4+ <?php
5+ $ a = ['existing ' => 0 ];
6+
7+ ob_start (function () use (&$ a ) {
8+ // Force several rehashes by adding many keys; the previously-allocated
9+ // bucket for $a['target'] (if it had been pre-fetched) would now point
10+ // into freed/relocated memory.
11+ for ($ i = 0 ; $ i < 64 ; $ i ++) {
12+ $ a ["k $ i " ] = $ i ;
13+ }
14+ return '' ;
15+ }, 1 );
16+
17+ // Triggers "Undefined variable" -> output handler -> rehash. Without the
18+ // fix the previously-fetched bucket pointer would be stale; with the fix
19+ // variable_ptr is fetched fresh after the warning.
20+ $ a ['target ' ] = $ undef ;
21+
22+ ob_end_clean ();
23+ var_dump ($ a ['target ' ], count ($ a ));
24+ echo "ok \n" ;
25+ ?>
26+ --EXPECT--
27+ NULL
28+ int(66)
29+ ok
You can’t perform that action at this time.
0 commit comments