mirror of
https://github.com/php/php-src.git
synced 2024-12-15 21:05:51 +08:00
Fixed GH-12511: Use must be in next opline assertion with patched infection
This commit is contained in:
parent
abe3673d1f
commit
b3b46a44c5
@ -3312,10 +3312,18 @@ static zend_always_inline int _zend_update_type_info(
|
||||
zend_uchar opcode;
|
||||
|
||||
if (!ssa_opcodes) {
|
||||
ZEND_ASSERT(j == (opline - op_array->opcodes) + 1 && "Use must be in next opline");
|
||||
if (j != (opline - op_array->opcodes) + 1) {
|
||||
/* Use must be in next opline */
|
||||
tmp |= key_type | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
|
||||
break;
|
||||
}
|
||||
opcode = op_array->opcodes[j].opcode;
|
||||
} else {
|
||||
ZEND_ASSERT(ssa_opcodes[j] == opline + 1 && "Use must be in next opline");
|
||||
if (ssa_opcodes[j] != opline + 1) {
|
||||
/* Use must be in next opline */
|
||||
tmp |= key_type | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
|
||||
break;
|
||||
}
|
||||
opcode = ssa_opcodes[j]->opcode;
|
||||
}
|
||||
switch (opcode) {
|
||||
@ -3374,7 +3382,10 @@ static zend_always_inline int _zend_update_type_info(
|
||||
EMPTY_SWITCH_DEFAULT_CASE()
|
||||
}
|
||||
j = zend_ssa_next_use(ssa->ops, ssa_op->result_def, j);
|
||||
ZEND_ASSERT(j < 0 && "There should only be one use");
|
||||
if (j >= 0) {
|
||||
tmp |= key_type | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (((tmp & MAY_BE_ARRAY) && (tmp & MAY_BE_ARRAY_KEY_ANY))
|
||||
|
17
ext/opcache/tests/opt/inference_022.phpt
Normal file
17
ext/opcache/tests/opt/inference_022.phpt
Normal file
@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
Type inference 022: FETCH_DIM_W
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.optimization_level=-1
|
||||
--FILE--
|
||||
<?php
|
||||
function &foo(&$a, $n) {
|
||||
foreach (array(0) as $_) {
|
||||
return $a[$n];
|
||||
}
|
||||
}
|
||||
?>
|
||||
DONE
|
||||
--EXPECT--
|
||||
DONE
|
Loading…
Reference in New Issue
Block a user