laruence

Untitled

Jul 9th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.25 KB | None | 0 0
  1. diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
  2. index 62b58b4..fadaff5 100644
  3. --- a/Zend/zend_opcode.c
  4. +++ b/Zend/zend_opcode.c
  5. @@ -550,7 +550,7 @@ static void zend_resolve_fast_call(zend_op_array *op_array, uint32_t fast_call,
  6.     }
  7.  }
  8.  
  9. -static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num)
  10. +static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num, uint32_t num_ops)
  11.  {
  12.     uint32_t start_op;
  13.     zend_op *opline;
  14. @@ -624,8 +624,14 @@ static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num,
  15.             }
  16.  
  17.             /* Finish the sequence with original opcode */
  18. -           opline = get_next_op(op_array);
  19. -           *opline = op_array->opcodes[op_num];
  20. +
  21. +           i = 0;
  22. +           while (i < num_ops) {
  23. +               opline = get_next_op(op_array);
  24. +               *opline = op_array->opcodes[op_num + i];
  25. +               MAKE_NOP((op_array->opcodes + op_num + i));
  26. +               i++;
  27. +           }
  28.  
  29.             /* Replace original opcode with jump to this sequence */
  30.             opline = op_array->opcodes + op_num;
  31. @@ -692,11 +698,19 @@ static void zend_resolve_finally_calls(zend_op_array *op_array)
  32.             case ZEND_RETURN:
  33.             case ZEND_RETURN_BY_REF:
  34.             case ZEND_GENERATOR_RETURN:
  35. -               zend_resolve_finally_call(op_array, i, (uint32_t)-1);
  36. +               {
  37. +                   uint32_t jmp = i;
  38. +                   while (jmp-- > 0
  39. +                       && (op_array->opcodes[jmp].opcode == ZEND_FREE
  40. +                       || op_array->opcodes[jmp].opcode == ZEND_FE_FREE)) {
  41. +                       jmp--;
  42. +                   }
  43. +                   zend_resolve_finally_call(op_array, jmp + 1, (uint32_t)-1, i - jmp);
  44. +               }
  45.                 break;
  46.             case ZEND_BRK:
  47.             case ZEND_CONT:
  48. -               zend_resolve_finally_call(op_array, i, zend_get_brk_cont_target(op_array, opline));
  49. +               zend_resolve_finally_call(op_array, i, zend_get_brk_cont_target(op_array, opline), 1);
  50.                 break;
  51.             case ZEND_GOTO:
  52.                 if (Z_TYPE_P(CT_CONSTANT_EX(op_array, opline->op2.constant)) != IS_LONG) {
  53. @@ -705,7 +719,7 @@ static void zend_resolve_finally_calls(zend_op_array *op_array)
  54.                 }
  55.                 /* break omitted intentionally */
  56.             case ZEND_JMP:
  57. -               zend_resolve_finally_call(op_array, i, opline->op1.opline_num);
  58. +               zend_resolve_finally_call(op_array, i, opline->op1.opline_num, 1);
  59.                 break;
  60.             case ZEND_FAST_CALL:
  61.                 zend_resolve_fast_call(op_array, i, i);
Advertisement
Add Comment
Please, Sign In to add comment