Skip to content

Commit 8907da9

Browse files
Set called_scope in Closure::call (fixes bug #70987)
1 parent a347b0b commit 8907da9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Zend/tests/bug70987.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #70987 (static::class within Closure::call() causes segfault)
3+
--FILE--
4+
<?php
5+
6+
class foo {}
7+
$bar = function () {
8+
return static::class;
9+
};
10+
11+
var_dump($bar->call(new foo));
12+
13+
?>
14+
--EXPECTF--
15+
string(3) "foo"

Zend/zend_closures.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ ZEND_METHOD(Closure, call)
150150
fci.param_count = my_param_count;
151151
fci.object = fci_cache.object = newobj;
152152
fci_cache.initialized = 1;
153+
fci_cache.called_scope = Z_OBJCE_P(newthis);
153154

154155
if (fci_cache.function_handler->common.fn_flags & ZEND_ACC_GENERATOR) {
155156
zval new_closure;

0 commit comments

Comments
 (0)