]> granicus.if.org Git - php/commitdiff
Set called_scope in Closure::call (fixes bug #70987)
authorAndrea Faulds <ajf@ajf.me>
Fri, 27 Nov 2015 15:06:13 +0000 (15:06 +0000)
committerAndrea Faulds <ajf@ajf.me>
Fri, 27 Nov 2015 15:06:13 +0000 (15:06 +0000)
Zend/tests/bug70987.phpt [new file with mode: 0644]
Zend/zend_closures.c

diff --git a/Zend/tests/bug70987.phpt b/Zend/tests/bug70987.phpt
new file mode 100644 (file)
index 0000000..d31a1d2
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Bug #70987 (static::class within Closure::call() causes segfault)
+--FILE--
+<?php
+
+class foo {}
+$bar = function () {
+   return static::class;
+};
+
+var_dump($bar->call(new foo));
+
+?>
+--EXPECTF--
+string(3) "foo"
index 76b10e43d3bde2987ac17eab01b430bcd0edb683..beca1cef0750c6e74eb94aa77c287f11e212a63b 100644 (file)
@@ -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;