Skip to content

Commit c67fa3c

Browse files
committed
Fixed bug #72943 (assign_dim on string doesn't reset hval)
1 parent 57509fb commit c67fa3c

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PHP NEWS
33
?? ??? 2016 PHP 7.0.11
44

55
- Core:
6+
. Fixed bug #72943 (assign_dim on string doesn't reset hval). (Laruence)
67
. Fixed bug #72911 (Memleak in zend_binary_assign_op_obj_helper). (Laruence)
78
. Fixed bug #72813 (Segfault with __get returned by ref). (Laruence)
89
. Fixed bug #72767 (PHP Segfaults when trying to expand an infinite operator).

Zend/tests/bug72943.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #72943 (assign_dim on string doesn't reset hval)
3+
--FILE--
4+
<?php
5+
$array = array("test" => 1);
6+
7+
$a = "lest";
8+
var_dump($array[$a]);
9+
$a[0] = "f";
10+
var_dump($array[$a]);
11+
$a[0] = "t";
12+
var_dump($array[$a]);
13+
?>
14+
--EXPECTF--
15+
Notice: Undefined index: lest in %sbug72943.php on line %d
16+
NULL
17+
18+
Notice: Undefined index: fest in %sbug72943.php on line %d
19+
NULL
20+
int(1)

Zend/zend_execute.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,7 @@ static void zend_assign_to_string_offset(zval *str, zend_long offset, zval *valu
13351335
zend_string_release(tmp);
13361336
} else {
13371337
Z_STRVAL_P(str)[offset] = Z_STRVAL_P(value)[0];
1338+
zend_string_forget_hash_val(Z_STR_P(str));
13381339
}
13391340
/*
13401341
* the value of an assignment to a string offset is undefined

0 commit comments

Comments
 (0)