Set called_scope in Closure::call (fixes bug #70987)

This commit is contained in:
Andrea Faulds 2015-11-27 15:06:13 +00:00
parent a347b0be48
commit 8907da99b8
2 changed files with 16 additions and 0 deletions

15
Zend/tests/bug70987.phpt Normal file
View file

@ -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"

View 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;