summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rwxr-xr-xZend/tests/bug30707.phpt29
-rw-r--r--Zend/zend_execute.c7
3 files changed, 37 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index fd43d14116..7057fdb3cf 100644
--- a/NEWS
+++ b/NEWS
@@ -72,6 +72,7 @@ PHP NEWS
- Fixed bug #30889 (Conflict between __get/__set and ++ operator). (Dmitry)
- Fixed bug #30833 (array_count_values() modifying input array). (Tony)
- Fixed bug #30819 (Better support for LDAP SASL bind). (Jani)
+- Fixed bug #30707 (Segmentation fault on exception in method). (Stas, Dmitry)
- Fixed bug #30702 (cannot initialize class variable from class constant).
(Dmitry)
- Fixed bug #30332 (zend.ze1_compatibility_mode isnt fully compatable with
diff --git a/Zend/tests/bug30707.phpt b/Zend/tests/bug30707.phpt
new file mode 100755
index 0000000000..d37d32974e
--- /dev/null
+++ b/Zend/tests/bug30707.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #30707 (Segmentation fault on exception in method)
+--FILE--
+<?php
+class C {
+ function byePHP($plop) {
+ echo "ok\n";
+ }
+
+ function plip() {
+ try {
+ $this->plap($this->plop());
+ } catch(Exception $e) {
+ }
+ }
+
+ function plap($a) {
+ }
+
+ function plop() {
+ throw new Exception;
+ }
+}
+
+$x = new C;
+$x->byePHP($x->plip());
+?>
+--EXPECT--
+ok
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 6de376dad1..a09d8a9094 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -4334,6 +4334,13 @@ int zend_handle_exception_handler(ZEND_OPCODE_HANDLER_ARGS)
}
}
+ while (EX(fbc)) {
+ if (EX(object)) {
+ zval_ptr_dtor(&EX(object));
+ }
+ zend_ptr_stack_n_pop(&EG(arg_types_stack), 3, &EX(calling_scope), &EX(object), &EX(fbc));
+ }
+
if (encapsulating_block == -1) {
RETURN_FROM_EXECUTE_LOOP(execute_data);
} else {