summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-10-09 11:48:13 +0300
committerDmitry Stogov <dmitry@zend.com>2015-10-09 11:48:13 +0300
commit0847681b1ab40193815285a4e9736a058372bb8c (patch)
tree03a4706da6207fa8f4e4e07f8e985b83ed3a691a
parentc6af0aa33f6dafe90f60b3d20231837f9e25dfb6 (diff)
downloadphp-git-0847681b1ab40193815285a4e9736a058372bb8c.tar.gz
Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure())
-rw-r--r--NEWS2
-rw-r--r--Zend/tests/bug70630.phpt10
-rw-r--r--Zend/zend_closures.c1
3 files changed, 13 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 3410a6d5f1..abf828e4eb 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 0000000000..fc79949ce2
--- /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 a394c91c60..4430e7b250 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;