com php-src: Improve previous fix: Zend/tests/bug70681.phpt Zend/zend_closures.c

From: Date: Fri, 09 Oct 2015 21:28:24 +0000
Subject: com php-src: Improve previous fix: Zend/tests/bug70681.phpt Zend/zend_closures.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89349@lists.php.net to get a copy of this message
Commit: e19423f3cbeaf2ac57a4af1e7c5b84fc6721177b Author: Nikita Popov <nikic@php.net> Fri, 9 Oct 2015 23:28:24 +0200 Parents: bbae7ddf29192af25a3a776dfc52508c162d2ea6 Branches: PHP-5.6 PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e19423f3cbeaf2ac57a4af1e7c5b84fc6721177b Log: Improve previous fix Don't forbid null binding on plain functions. Changed paths: M Zend/tests/bug70681.phpt M Zend/zend_closures.c Diff: diff --git a/Zend/tests/bug70681.phpt b/Zend/tests/bug70681.phpt index a99180b..9dd09b0 100644 --- a/Zend/tests/bug70681.phpt +++ b/Zend/tests/bug70681.phpt @@ -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) diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 772eb12..582a1f7 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -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; }

« previous php.cvs (#89349) next »