Skip to content

Instantly share code, notes, and snippets.

@dstogov
Created November 11, 2021 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstogov/1976b98a821a0e31c8cba737efdac88a to your computer and use it in GitHub Desktop.
Save dstogov/1976b98a821a0e31c8cba737efdac88a to your computer and use it in GitHub Desktop.
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 9979a9b2fb..a98a3480d3 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -9857,6 +9857,20 @@ ZEND_VM_HELPER(zend_interrupt_helper, ANY, ANY)
zend_timeout();
} else if (zend_interrupt_function) {
zend_interrupt_function(execute_data);
+ if (EG(exception)) {
+ /* We have to UNDEF result, because ZEND_HANDLE_EXCEPTION is going to free it */
+ zend_op *throw_op = EG(opline_before_exception);
+
+ if (throw_op
+ && throw_op->result_type & (IS_TMP_VAR|IS_VAR)
+ && throw_op->opcode != ZEND_ADD_ARRAY_ELEMENT
+ && throw_op->opcode != ZEND_ADD_ARRAY_UNPACK
+ && throw_op->opcode != ZEND_ROPE_INIT
+ && throw_op->opcode != ZEND_ROPE_ADD) {
+ ZVAL_UNDEF(ZEND_CALL_VAR(EG(current_execute_data), throw_op->result.var));
+
+ }
+ }
ZEND_VM_ENTER();
}
ZEND_VM_CONTINUE();
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 4a26e0c252..2629a5761a 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -3528,6 +3528,20 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_interrupt_he
zend_timeout();
} else if (zend_interrupt_function) {
zend_interrupt_function(execute_data);
+ if (EG(exception)) {
+ /* We have to UNDEF result, because ZEND_HANDLE_EXCEPTION is going to free it */
+ zend_op *throw_op = EG(opline_before_exception);
+
+ if (throw_op
+ && throw_op->result_type & (IS_TMP_VAR|IS_VAR)
+ && throw_op->opcode != ZEND_ADD_ARRAY_ELEMENT
+ && throw_op->opcode != ZEND_ADD_ARRAY_UNPACK
+ && throw_op->opcode != ZEND_ROPE_INIT
+ && throw_op->opcode != ZEND_ROPE_ADD) {
+ ZVAL_UNDEF(ZEND_CALL_VAR(EG(current_execute_data), throw_op->result.var));
+
+ }
+ }
ZEND_VM_ENTER();
}
ZEND_VM_CONTINUE();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment