Commit:    9cf3e65391d6aa637e5471449499e957cff6ee89
Author:    Xinchen Hui <larue...@php.net>         Mon, 24 Jun 2013 23:45:08 
+0800
Parents:   a0d48e01edb90a6b9a3db39104b9d7b098001dba
Branches:  PHP-5.4

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=9cf3e65391d6aa637e5471449499e957cff6ee89

Log:
Fixed bug (is_callable() triggers Fatal Error)

This bug is also exists in 5.4, and previous fix by dsp is not complete
for __callStatic stituation, see test script

Changed paths:
  M  NEWS
  A  Zend/tests/bug65108.phpt
  M  Zend/zend_API.c


Diff:
diff --git a/NEWS b/NEWS
index 9ec6740..2dbe468 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP                                                             
           NEWS
 ?? ??? 2013, PHP 5.4.18
 
 - Core:
+  . Fixed bug #65108 (is_callable() triggers Fatal Error). 
+    (David Soria Parra, Laruence)
   . Fixed bug #65088 (Generated configure script is malformed on OpenBSD).
     (Adam)
 
diff --git a/Zend/tests/bug65108.phpt b/Zend/tests/bug65108.phpt
new file mode 100644
index 0000000..d3e5a65
--- /dev/null
+++ b/Zend/tests/bug65108.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #65108 (is_callable() triggers Fatal Error)
+--FILE--
+<?php
+class C {
+       private function f() {}
+       static function __callStatic($name, $args) {}
+}
+
+class B {
+       public function B() {
+               $isCallable = is_callable(array(new C, 'f'));
+               var_dump($isCallable);
+       }
+}
+
+new B();
+
+Class E {
+   private function f() {}
+   function __call($name, $args) {}
+}
+$isCallable = is_callable(array('E', 'f'));
+var_dump($isCallable);
+--EXPECT--
+bool(false)
+bool(false)
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index e1f80c7..90d27b7 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -2779,8 +2779,8 @@ static int zend_is_callable_check_func(int check_flags, 
zval *callable, zend_fca
                }
                if ((check_flags & IS_CALLABLE_CHECK_NO_ACCESS) == 0 &&
                    (fcc->calling_scope &&
-                    (fcc->calling_scope->__call ||
-                     fcc->calling_scope->__callstatic))) {
+                    ((fcc->object_ptr && fcc->calling_scope->__call) ||
+                     (!fcc->object_ptr && fcc->calling_scope->__callstatic)))) 
{
                        if (fcc->function_handler->op_array.fn_flags & 
ZEND_ACC_PRIVATE) {
                                if (!zend_check_private(fcc->function_handler, 
fcc->object_ptr ? Z_OBJCE_P(fcc->object_ptr) : EG(scope), lmname, mlen 
TSRMLS_CC)) {
                                        retval = 0;


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to