com php-src: Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure()): NEWS Zend/tests/bug70630.phpt Zend/zend_closures.c
| From: | Dmitry Stogov | Date: | Fri, 09 Oct 2015 08:48:13 +0000 |
| Subject: | com php-src: Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure()): NEWS Zend/tests/bug70630.phpt Zend/zend_closures.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89345@lists.php.net to get a copy of this message | ||
Commit: 0847681b1ab40193815285a4e9736a058372bb8c
Author: Dmitry Stogov <dmitry@zend.com> Fri, 9 Oct 2015 11:48:13 +0300
Parents: c6af0aa33f6dafe90f60b3d20231837f9e25dfb6
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0847681b1ab40193815285a4e9736a058372bb8c
Log:
Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure())
Bugs:
https://bugs.php.net/70630
Changed paths:
M NEWS
A Zend/tests/bug70630..phpt
M Zend/zend_closures.c
Diff:
diff --git a/NEWS b/NEWS
index 3410a6d..abf828e 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP NEWS
15 Oct 2015, PHP 7.0.0 RC 5
- Core:
+ . Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->
+ getClosure()). (Dmitry, Bob)
. Fixed bug #70662 (Duplicate array key via undefined index error handler).
(Nikita)
diff --git a/Zend/tests/bug70630.phpt b/Zend/tests/bug70630.phpt
new file mode 100644
index 0000000..fc79949
--- /dev/null
+++ b/Zend/tests/bug70630.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure())
+--FILE--
+<?php
+class a {}
+$x = (new ReflectionFunction("substr"))->getClosure();
+$x->call(new a);
+?>
+--EXPECTF--
+Warning: a::substr() expects at least 2 parameters, 0 given in %s on line %d
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c
index a394c91..4430e7b 100644
--- a/Zend/zend_closures.c
+++ b/Zend/zend_closures.c
@@ -98,6 +98,7 @@ ZEND_METHOD(Closure, call)
if (closure->func.type == ZEND_INTERNAL_FUNCTION) {
/* verify that we aren't binding internal function to a wrong object */
if ((closure->func.common.fn_flags & ZEND_ACC_STATIC) == 0 &&
+ closure->func.common.scope &&
!instanceof_function(Z_OBJCE_P(newthis), closure->func.common.scope)) {
zend_error(E_WARNING, "Cannot bind function %s::%s to object of class %s",
ZSTR_VAL(closure->func.common.scope->name), ZSTR_VAL(closure->func.common.function_name),
ZSTR_VAL(Z_OBJCE_P(newthis)->name));
return;