mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Improve previous fix
Don't forbid null binding on plain functions.
This commit is contained in:
parent
bbae7ddf29
commit
e19423f3cb
@ -6,6 +6,11 @@ Bug #70681: Segfault when binding $this of internal instance method to null
|
||||
$c = (new ReflectionMethod('SplStack', 'count'))->getClosure(new SplStack);
|
||||
$c = $c->bindTo(null);
|
||||
|
||||
$c = (new ReflectionFunction('strlen'))->getClosure();
|
||||
$c = $c->bindTo(null);
|
||||
var_dump($c("foo"));
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Cannot unbind $this of internal method in %s on line %d
|
||||
int(3)
|
||||
|
@ -89,7 +89,7 @@ ZEND_METHOD(Closure, bind)
|
||||
}
|
||||
|
||||
if (newthis == NULL && !(closure->func.common.fn_flags & ZEND_ACC_STATIC)
|
||||
&& closure->func.type == ZEND_INTERNAL_FUNCTION) {
|
||||
&& closure->func.common.scope && closure->func.type == ZEND_INTERNAL_FUNCTION) {
|
||||
zend_error(E_WARNING, "Cannot unbind $this of internal method");
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user