Skip to content

Commit 242d924

Browse files
committed
Fix bug #73847
1 parent eb25e14 commit 242d924

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ PHP NEWS
3737
. Fixed bug #73654 (Segmentation fault in zend_call_function). (Nikita)
3838
. Fixed bug #73668 ("SIGFPE Arithmetic exception" in opcache when divide by
3939
minus 1). (Nikita)
40+
. Fixed bug #73847 (Recursion when a variable is redefined as array). (Nikita)
4041

4142
- PDO_Firebird:
4243
. Fixed bug #72931 (PDO_FIREBIRD with Firebird 3.0 not work on returning

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)