]> granicus.if.org Git - php/commitdiff
Fix Closure leak in aborted INIT_DYNAMIC_FCALL
authorBob Weinand <bobwei9@hotmail.com>
Fri, 26 Jun 2015 03:10:58 +0000 (05:10 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Fri, 26 Jun 2015 03:10:58 +0000 (05:10 +0200)
Zend/tests/closure_call_leak_with_exception.phpt [new file with mode: 0644]
Zend/zend_execute.c

diff --git a/Zend/tests/closure_call_leak_with_exception.phpt b/Zend/tests/closure_call_leak_with_exception.phpt
new file mode 100644 (file)
index 0000000..07374c7
--- /dev/null
@@ -0,0 +1,14 @@
+--FILE--
+Closure must not leak during a dynmaic call interrupted by an exception
+--TEST--
+<?php
+
+(function() {
+       $closure = function($foo) { var_dump($foo); };
+       $closure(yield);
+})()->valid(); // start
+
+?>
+==DONE==
+--EXPECT--
+==DONE==
index 8fc40245c95025d741c0f286f9b676ea6276b680..e80f42992dee773f4439f104be0f64e64669fbc9 100644 (file)
@@ -2486,6 +2486,9 @@ static zend_always_inline void i_cleanup_unfinished_execution(zend_execute_data
                                }
                                OBJ_RELEASE(Z_OBJ(call->This));
                        }
+                       if (call->func->common.fn_flags & ZEND_ACC_CLOSURE) {
+                               zend_object_release(call->func->common.prototype);
+                       }
                        if (call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
                                zend_string_release(call->func->common.function_name);
                                zend_free_trampoline(call->func);