From 9e89f91341be5550f90563f9d531d9fbef44dbd3 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 13 Mar 2020 13:11:42 +0100 Subject: [PATCH] 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. --- ext/opcache/Optimizer/zend_inference.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index da40b59e6c..e11c3cd9c7 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -3299,6 +3299,7 @@ static int zend_update_type_info(const zend_op_array *op_array, || opline->opcode == ZEND_FETCH_LIST_W) { j = ssa_vars[ssa_ops[i].result_def].use_chain; while (j >= 0) { + ZEND_ASSERT(j == i + 1 && "Use must be in next opline"); switch (op_array->opcodes[j].opcode) { case ZEND_FETCH_DIM_W: case ZEND_FETCH_DIM_RW: @@ -3354,6 +3355,7 @@ static int zend_update_type_info(const zend_op_array *op_array, EMPTY_SWITCH_DEFAULT_CASE() } j = zend_ssa_next_use(ssa_ops, ssa_ops[i].result_def, j); + ZEND_ASSERT(j < 0 && "There should only be one use"); } } if ((tmp & MAY_BE_ARRAY) && (tmp & MAY_BE_ARRAY_KEY_ANY)) { -- 2.50.1