From 8907da99b83204958cb2308ec12aa9e490372150 Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Fri, 27 Nov 2015 15:06:13 +0000 Subject: [PATCH] Set called_scope in Closure::call (fixes bug #70987) --- Zend/tests/bug70987.phpt | 15 +++++++++++++++ Zend/zend_closures.c | 1 + 2 files changed, 16 insertions(+) create mode 100644 Zend/tests/bug70987.phpt diff --git a/Zend/tests/bug70987.phpt b/Zend/tests/bug70987.phpt new file mode 100644 index 00000000000..d31a1d2c6e8 --- /dev/null +++ b/Zend/tests/bug70987.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #70987 (static::class within Closure::call() causes segfault) +--FILE-- +call(new foo)); + +?> +--EXPECTF-- +string(3) "foo" diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 76b10e43d3b..beca1cef075 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -150,6 +150,7 @@ ZEND_METHOD(Closure, call) fci.param_count = my_param_count; fci.object = fci_cache.object = newobj; fci_cache.initialized = 1; + fci_cache.called_scope = Z_OBJCE_P(newthis); if (fci_cache.function_handler->common.fn_flags & ZEND_ACC_GENERATOR) { zval new_closure;