summaryrefslogtreecommitdiff
path: root/Zend/tests/bug79793.phpt
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-07-07 16:24:13 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-07-07 16:29:48 +0200
commit77acc8a069acbdd0e4ab0ac43f7d676a23e413a1 (patch)
tree3cc260f2071b4cfbdac17c4e85a270629360edc5 /Zend/tests/bug79793.phpt
parent62bec0e083aee4cba17d459fb4e07e1599772b12 (diff)
downloadphp-git-77acc8a069acbdd0e4ab0ac43f7d676a23e413a1.tar.gz
Fixed bug #79793
Make sure the string key is not released while throwing the undefined index warning.
Diffstat (limited to 'Zend/tests/bug79793.phpt')
-rw-r--r--Zend/tests/bug79793.phpt32
1 files changed, 32 insertions, 0 deletions
diff --git a/Zend/tests/bug79793.phpt b/Zend/tests/bug79793.phpt
new file mode 100644
index 0000000000..9e4e2e20be
--- /dev/null
+++ b/Zend/tests/bug79793.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #79793: Use after free if string used in undefined index warning is changed
+--FILE--
+<?php
+
+$key = "foo";
+$key .= "bar";
+set_error_handler(function($_, $m) use (&$key) {
+ echo "$m\n";
+ $key .= "baz";
+});
+
+$ary = [];
+$ary[$key]++;
+var_dump($ary);
+$ary[$key] += 1;
+var_dump($ary);
+
+?>
+--EXPECT--
+Undefined index: foobar
+array(1) {
+ ["foobar"]=>
+ int(1)
+}
+Undefined index: foobarbaz
+array(2) {
+ ["foobar"]=>
+ int(1)
+ ["foobarbaz"]=>
+ int(1)
+}