diff --git a/Zend/Optimizer/zend_ssa.c b/Zend/Optimizer/zend_ssa.c index fec5609d46e..47202ab755c 100644 --- a/Zend/Optimizer/zend_ssa.c +++ b/Zend/Optimizer/zend_ssa.c @@ -284,6 +284,14 @@ static void place_essa_pis( default: continue; } + + /* The following patterns all inspect the opline directly before the JMPZ opcode. + * Make sure that it is part of the same block, otherwise it might not be a dominating + * assignment. */ + if (blocks[j].len == 1) { + continue; + } + if (opline->op1_type == IS_TMP_VAR && ((opline-1)->opcode == ZEND_IS_EQUAL || (opline-1)->opcode == ZEND_IS_NOT_EQUAL || diff --git a/ext/opcache/tests/bug81015.phpt b/ext/opcache/tests/bug81015.phpt new file mode 100644 index 00000000000..b5009e6a236 --- /dev/null +++ b/ext/opcache/tests/bug81015.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #81015: Opcache optimization assumes wrong part of ternary operator in if-condition +--FILE-- + +--EXPECT-- +value +NULL +INVALID +NULL