xref: /PHP-7.4/Zend/tests/bug79793.phpt (revision 77acc8a0)
1--TEST--
2Bug #79793: Use after free if string used in undefined index warning is changed
3--FILE--
4<?php
5
6$key = "foo";
7$key .= "bar";
8set_error_handler(function($_, $m) use (&$key) {
9    echo "$m\n";
10    $key .= "baz";
11});
12
13$ary = [];
14$ary[$key]++;
15var_dump($ary);
16$ary[$key] += 1;
17var_dump($ary);
18
19?>
20--EXPECT--
21Undefined index: foobar
22array(1) {
23  ["foobar"]=>
24  int(1)
25}
26Undefined index: foobarbaz
27array(2) {
28  ["foobar"]=>
29  int(1)
30  ["foobarbaz"]=>
31  int(1)
32}
33