com php-src: Fix bug #73847: NEWS ext/opcache/Optimizer/dfa_p ass.c ext/opcache/tests/bug73847.phpt

From: Date: Sat, 31 Dec 2016 12:33:21 +0000
Subject: com php-src: Fix bug #73847: NEWS ext/opcache/Optimizer/dfa_p ass.c ext/opcache/tests/bug73847.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-96462@lists.php.net to get a copy of this message
Commit: 242d924e599d2c92a5d12873ad1564f7d44f7126 Author: Nikita Popov <nikic@php.net> Sat, 31 Dec 2016 13:33:21 +0100 Parents: eb25e1496277079423bdf2dee5aa4133c49e1f53 Branches: PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=242d924e599d2c92a5d12873ad1564f7d44f7126 Log: Fix bug #73847 Bugs: https://bugs.php.net/73847 Changed paths: M NEWS M ext/opcache/Optimizer/dfa_pass.c A ext/opcache/tests/bug73847.phpt Diff: diff --git a/NEWS b/NEWS index 9d1a2c5..d06b6c4 100644 --- a/NEWS +++ b/NEWS @@ -37,6 +37,7 @@ PHP NEWS . Fixed bug #73654 (Segmentation fault in zend_call_function). (Nikita) . Fixed bug #73668 ("SIGFPE Arithmetic exception" in opcache when divide by minus 1). (Nikita) + . Fixed bug #73847 (Recursion when a variable is redefined as array). (Nikita) - PDO_Firebird: . Fixed bug #72931 (PDO_FIREBIRD with Firebird 3.0 not work on returning diff --git a/ext/opcache/Optimizer/dfa_pass.c b/ext/opcache/Optimizer/dfa_pass.c index 2780a4c..f01e2ec 100644 --- a/ext/opcache/Optimizer/dfa_pass.c +++ b/ext/opcache/Optimizer/dfa_pass.c @@ -356,6 +356,12 @@ static zend_bool opline_supports_assign_contraction( return opline->op1_type != IS_CV || opline->op1.var != cv_var; } + if (opline->opcode == ZEND_INIT_ARRAY) { + /* INIT_ARRAY initializes the result array before reading key/value. */ + return (opline->op1_type != IS_CV || opline->op1.var != cv_var) + && (opline->op2_type != IS_CV || opline->op2.var != cv_var); + } + return 1; } diff --git a/ext/opcache/tests/bug73847.phpt b/ext/opcache/tests/bug73847.phpt new file mode 100644 index 0000000..7010dfb --- /dev/null +++ b/ext/opcache/tests/bug73847.phpt @@ -0,0 +1,44 @@ +--TEST-- +Bug #73847: Recursion when a variable is redefined as array +--FILE-- +<?php +function test() { + $a = 42; + $a = array($a); + var_dump($a); + + $a = 42; + $a = array($a => 24); + var_dump($a); + + $a = 42; + $a = array($a, 24); + var_dump($a); + + $a = 42; + $a = array(24, $a); + var_dump($a); +} +test(); +?> +--EXPECT-- +array(1) { + [0]=> + int(42) +} +array(1) { + [42]=> + int(24) +} +array(2) { + [0]=> + int(42) + [1]=> + int(24) +} +array(2) { + [0]=> + int(24) + [1]=> + int(42) +}

« previous php.cvs (#96462) next »