dmitry                                   Tue, 31 May 2011 11:36:57 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=311653

Log:
MFH: Fixed bug #54910 (Crash when calling call_user_func with unknown function 
name)

Bug: http://bugs.php.net/54910 (Closed) Crash when calling call_user_func with 
unknown function name
      
Changed paths:
    A   php/php-src/branches/PHP_5_4/Zend/tests/bug54910.phpt
    U   php/php-src/branches/PHP_5_4/Zend/zend_API.c

Added: php/php-src/branches/PHP_5_4/Zend/tests/bug54910.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/tests/bug54910.phpt                       
        (rev 0)
+++ php/php-src/branches/PHP_5_4/Zend/tests/bug54910.phpt       2011-05-31 
11:36:57 UTC (rev 311653)
@@ -0,0 +1,28 @@
+--TEST--
+Bug #54910 (Crash when calling call_user_func with unknown function name)
+--FILE--
+<?php
+class A {
+    public function __call($method, $args) {
+        if (stripos($method, 'get') === 0) {
+            return $this->get();
+        }
+        die("No such method - '$method'\n");
+    }
+
+    protected function get() {
+        $class = get_class($this);
+        $call = array($class, 'noSuchMethod');
+
+        if (is_callable($call)) {
+            call_user_func($call);
+        }
+    }
+}
+
+class B extends A {}
+
+$input = new B();
+echo $input->getEmail();
+--EXPECT--
+No such method - 'noSuchMethod'

Modified: php/php-src/branches/PHP_5_4/Zend/zend_API.c
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/zend_API.c        2011-05-31 11:28:37 UTC 
(rev 311652)
+++ php/php-src/branches/PHP_5_4/Zend/zend_API.c        2011-05-31 11:36:57 UTC 
(rev 311653)
@@ -2773,6 +2773,11 @@
                        if (fcc->function_handler) {
                                retval = 1;
                                call_via_handler = 
(fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0;
+                               if (call_via_handler && !fcc->object_ptr && 
EG(This) &&
+                                   Z_OBJ_HT_P(EG(This))->get_class_entry &&
+                                   instanceof_function(Z_OBJCE_P(EG(This)), 
fcc->calling_scope TSRMLS_CC)) {
+                                       fcc->object_ptr = EG(This);
+                               }
                        }
                }
        }

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

Reply via email to