]> granicus.if.org Git - php/commitdiff
Fixed bug #72943 (assign_dim on string doesn't reset hval)
authorXinchen Hui <laruence@gmail.com>
Fri, 26 Aug 2016 10:30:08 +0000 (18:30 +0800)
committerXinchen Hui <laruence@gmail.com>
Fri, 26 Aug 2016 10:30:08 +0000 (18:30 +0800)
NEWS
Zend/tests/bug72943.phpt [new file with mode: 0644]
Zend/zend_execute.c

diff --git a/NEWS b/NEWS
index d215a2b6ce514e389b97b28c7ce49e59fe671bea..1fc159a17bc2cb0d574b392d060d85e6cb836f44 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PHP                                                                        NEWS
 ?? ??? 2016 PHP 7.0.11
 
 - Core:
+  . Fixed bug #72943 (assign_dim on string doesn't reset hval). (Laruence)
   . Fixed bug #72911 (Memleak in zend_binary_assign_op_obj_helper). (Laruence)
   . Fixed bug #72813 (Segfault with __get returned by ref). (Laruence)
   . Fixed bug #72767 (PHP Segfaults when trying to expand an infinite operator).
diff --git a/Zend/tests/bug72943.phpt b/Zend/tests/bug72943.phpt
new file mode 100644 (file)
index 0000000..8bab6de
--- /dev/null
@@ -0,0 +1,20 @@
+--TEST--
+Bug #72943 (assign_dim on string doesn't reset hval)
+--FILE--
+<?php
+$array = array("test" => 1);
+
+$a = "lest";
+var_dump($array[$a]);
+$a[0] = "f";
+var_dump($array[$a]);
+$a[0] = "t";
+var_dump($array[$a]);
+?>
+--EXPECTF--
+Notice: Undefined index: lest in %sbug72943.php on line %d
+NULL
+
+Notice: Undefined index: fest in %sbug72943.php on line %d
+NULL
+int(1)
index 9a3f69e026a6551b2d43146bf07685bca90f8fc0..2882f3dc33de5e69d7aaec4ec8b8c69def71fcde 100644 (file)
@@ -1335,6 +1335,7 @@ static void zend_assign_to_string_offset(zval *str, zend_long offset, zval *valu
                zend_string_release(tmp);
        } else {
                Z_STRVAL_P(str)[offset] = Z_STRVAL_P(value)[0];
+               zend_string_forget_hash_val(Z_STR_P(str));
        }
        /*
         * the value of an assignment to a string offset is undefined