Skip to content

Commit 84d7d4e

Browse files
committed
Fixed bug #76466 (Loop variable confusion)
1 parent 83a77f5 commit 84d7d4e

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ PHP NEWS
2222
- Opcache:
2323
. Fixed bug #76477 (Opcache causes empty return value).
2424
(Nikita, Laruence)
25+
. Fixed bug #76466 (Loop variable confusion). (Dmitry, Laruence, Nikita)
2526
. Fixed bug #76463 (var has array key type but not value type). (Laruence)
2627
. Fixed bug #76446 (zend_variables.c:73: zend_string_destroy: Assertion
2728
`!(zval_gc_flags((str)->gc)). (Nikita, Laruence)

ext/opcache/Optimizer/sccp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,7 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
12301230
* ADD_ARRAY_ELEMENT chain. We do this by only keeping the array on the last opcode
12311231
* and use a NULL value everywhere else. */
12321232
if (Z_TYPE(ctx->values[ssa_op->result_def]) == IS_NULL) {
1233+
SET_RESULT_BOT(result);
12331234
return;
12341235
}
12351236

ext/opcache/tests/bug76466.phpt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
Bug #76466 Loop variable confusion
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
--FILE--
10+
<?php
11+
function foo() {
12+
for ($i = 0; $i < 2; $i++) {
13+
$field_array[] = [$i, 0];
14+
}
15+
var_dump($field_array);
16+
}
17+
foo();
18+
?>
19+
--EXPECT--
20+
array(2) {
21+
[0]=>
22+
array(2) {
23+
[0]=>
24+
int(0)
25+
[1]=>
26+
int(0)
27+
}
28+
[1]=>
29+
array(2) {
30+
[0]=>
31+
int(1)
32+
[1]=>
33+
int(0)
34+
}
35+
}

0 commit comments

Comments
 (0)