1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fixed GH-12511: Use must be in next opline assertion with patched infection
This commit is contained in:
Dmitry Stogov
2023-10-31 07:52:46 +03:00
2 changed files with 31 additions and 3 deletions

View File

@@ -3348,10 +3348,18 @@ static zend_always_inline zend_result _zend_update_type_info(
uint8_t 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) {
@@ -3413,7 +3421,10 @@ static zend_always_inline zend_result _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))

View 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