Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bug69038
diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c
index a41d324..5db69f2 100644
--- a/ext/opcache/Optimizer/zend_optimizer.c
+++ b/ext/opcache/Optimizer/zend_optimizer.c
@@ -374,17 +374,41 @@ static void replace_tmp_by_const(zend_op_array *op_array,
* usually terminated by ZEND_FREE that finally kills the value.
*/
if (opline->opcode == ZEND_CASE) {
- zval old_val;
- old_val = *val;
- zval_copy_ctor(val);
- update_op1_const(op_array, opline, val TSRMLS_CC);
- *val = old_val;
+ zend_op *m, *n;
+ int brk = op_array->last_brk_cont;
+ while (brk--) {
+ if (op_array->brk_cont_array[brk].start <= (opline - op_array->opcodes) &&
+ op_array->brk_cont_array[brk].brk > (opline - op_array->opcodes)) {
+ break;
+ }
+ }
+ m = opline;
+ n = op_array->opcodes + op_array->brk_cont_array[brk].brk + 1;
+ while (m < n) {
+ if (ZEND_OP1_TYPE(opline) == IS_TMP_VAR &&
+ ZEND_OP1(opline).var == var) {
+ if (opline->opcode == ZEND_CASE) {
+ zval old_val;
+ old_val = *val;
+ zval_copy_ctor(val);
+ update_op1_const(op_array, m, val TSRMLS_CC);
+ *val = old_val;
+ } else if (opline->opcode == ZEND_FREE) {
+ MAKE_NOP(m);
+ } else {
+ ZEND_ASSERT(0);
+ }
+ }
+ m++;
+ }
+ zval_dtor(val);
+ break;
} else if (opline->opcode == ZEND_FREE) {
MAKE_NOP(opline);
+ zval_dtor(val);
break;
} else {
update_op1_const(op_array, opline, val TSRMLS_CC);
- val = NULL;
break;
}
}
@@ -394,14 +418,10 @@ static void replace_tmp_by_const(zend_op_array *op_array,
update_op2_const(op_array, opline, val TSRMLS_CC);
/* TMP_VAR may be used only once */
- val = NULL;
break;
}
opline++;
}
- if (val) {
- zval_dtor(val);
- }
}
#include "Optimizer/nop_removal.c"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.