Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
- index 62b58b4..fadaff5 100644
- --- a/Zend/zend_opcode.c
- +++ b/Zend/zend_opcode.c
- @@ -550,7 +550,7 @@ static void zend_resolve_fast_call(zend_op_array *op_array, uint32_t fast_call,
- }
- }
- -static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num)
- +static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num, uint32_t num_ops)
- {
- uint32_t start_op;
- zend_op *opline;
- @@ -624,8 +624,14 @@ static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num,
- }
- /* Finish the sequence with original opcode */
- - opline = get_next_op(op_array);
- - *opline = op_array->opcodes[op_num];
- +
- + i = 0;
- + while (i < num_ops) {
- + opline = get_next_op(op_array);
- + *opline = op_array->opcodes[op_num + i];
- + MAKE_NOP((op_array->opcodes + op_num + i));
- + i++;
- + }
- /* Replace original opcode with jump to this sequence */
- opline = op_array->opcodes + op_num;
- @@ -692,11 +698,19 @@ static void zend_resolve_finally_calls(zend_op_array *op_array)
- case ZEND_RETURN:
- case ZEND_RETURN_BY_REF:
- case ZEND_GENERATOR_RETURN:
- - zend_resolve_finally_call(op_array, i, (uint32_t)-1);
- + {
- + uint32_t jmp = i;
- + while (jmp-- > 0
- + && (op_array->opcodes[jmp].opcode == ZEND_FREE
- + || op_array->opcodes[jmp].opcode == ZEND_FE_FREE)) {
- + jmp--;
- + }
- + zend_resolve_finally_call(op_array, jmp + 1, (uint32_t)-1, i - jmp);
- + }
- break;
- case ZEND_BRK:
- case ZEND_CONT:
- - zend_resolve_finally_call(op_array, i, zend_get_brk_cont_target(op_array, opline));
- + zend_resolve_finally_call(op_array, i, zend_get_brk_cont_target(op_array, opline), 1);
- break;
- case ZEND_GOTO:
- if (Z_TYPE_P(CT_CONSTANT_EX(op_array, opline->op2.constant)) != IS_LONG) {
- @@ -705,7 +719,7 @@ static void zend_resolve_finally_calls(zend_op_array *op_array)
- }
- /* break omitted intentionally */
- case ZEND_JMP:
- - zend_resolve_finally_call(op_array, i, opline->op1.opline_num);
- + zend_resolve_finally_call(op_array, i, opline->op1.opline_num, 1);
- break;
- case ZEND_FAST_CALL:
- zend_resolve_fast_call(op_array, i, i);
Advertisement
Add Comment
Please, Sign In to add comment