Skip to content

Commit 5ac4973

Browse files
committed
Merge branch 'PHP-7.1'
* PHP-7.1: Fixed bug #72943 (assign_dim on string doesn't reset hval)
2 parents 9950485 + 557f1cc commit 5ac4973

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

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
@@ -1330,6 +1330,7 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim,
13301330
zend_string_release(old_str);
13311331
} else {
13321332
SEPARATE_STRING(str);
1333+
zend_string_forget_hash_val(Z_STR_P(str));
13331334
}
13341335

13351336
Z_STRVAL_P(str)[offset] = c;

0 commit comments

Comments
 (0)