Skip to content

Commit 9e89f91

Browse files
committed
Add assertions for DIM_W/RW uses
The result should be used only once and on the directly next opline, otherwise it may not be safe. Add some assertions to that effect.
1 parent 9ab2cb9 commit 9e89f91

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3299,6 +3299,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
32993299
|| opline->opcode == ZEND_FETCH_LIST_W) {
33003300
j = ssa_vars[ssa_ops[i].result_def].use_chain;
33013301
while (j >= 0) {
3302+
ZEND_ASSERT(j == i + 1 && "Use must be in next opline");
33023303
switch (op_array->opcodes[j].opcode) {
33033304
case ZEND_FETCH_DIM_W:
33043305
case ZEND_FETCH_DIM_RW:
@@ -3354,6 +3355,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
33543355
EMPTY_SWITCH_DEFAULT_CASE()
33553356
}
33563357
j = zend_ssa_next_use(ssa_ops, ssa_ops[i].result_def, j);
3358+
ZEND_ASSERT(j < 0 && "There should only be one use");
33573359
}
33583360
}
33593361
if ((tmp & MAY_BE_ARRAY) && (tmp & MAY_BE_ARRAY_KEY_ANY)) {

0 commit comments

Comments
 (0)