Skip to content

Commit ae1ecf1

Browse files
committed
Merge branch 'master' of git.php.net:/php-src
* 'master' of git.php.net:/php-src: Fix bug #73847
2 parents 890ae17 + b767370 commit ae1ecf1

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

ext/opcache/Optimizer/dfa_pass.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,12 @@ static zend_bool opline_supports_assign_contraction(
356356
return opline->op1_type != IS_CV || opline->op1.var != cv_var;
357357
}
358358

359+
if (opline->opcode == ZEND_INIT_ARRAY) {
360+
/* INIT_ARRAY initializes the result array before reading key/value. */
361+
return (opline->op1_type != IS_CV || opline->op1.var != cv_var)
362+
&& (opline->op2_type != IS_CV || opline->op2.var != cv_var);
363+
}
364+
359365
return 1;
360366
}
361367

ext/opcache/tests/bug73847.phpt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--TEST--
2+
Bug #73847: Recursion when a variable is redefined as array
3+
--FILE--
4+
<?php
5+
function test() {
6+
$a = 42;
7+
$a = array($a);
8+
var_dump($a);
9+
10+
$a = 42;
11+
$a = array($a => 24);
12+
var_dump($a);
13+
14+
$a = 42;
15+
$a = array($a, 24);
16+
var_dump($a);
17+
18+
$a = 42;
19+
$a = array(24, $a);
20+
var_dump($a);
21+
}
22+
test();
23+
?>
24+
--EXPECT--
25+
array(1) {
26+
[0]=>
27+
int(42)
28+
}
29+
array(1) {
30+
[42]=>
31+
int(24)
32+
}
33+
array(2) {
34+
[0]=>
35+
int(42)
36+
[1]=>
37+
int(24)
38+
}
39+
array(2) {
40+
[0]=>
41+
int(24)
42+
[1]=>
43+
int(42)
44+
}

0 commit comments

Comments
 (0)