]> granicus.if.org Git - php/commitdiff
Fixed bug #71442 (forward_static_call crash)
authorXinchen Hui <laruence@gmail.com>
Mon, 25 Jan 2016 04:13:22 +0000 (12:13 +0800)
committerXinchen Hui <laruence@gmail.com>
Mon, 25 Jan 2016 04:13:22 +0000 (12:13 +0800)
NEWS
ext/standard/basic_functions.c
ext/standard/tests/class_object/bug71442.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 7740472ebda3aa197ebc7b9b23221fa17fc4e1f7..ec4df90e200d918112c355282beee468acb993dd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PHP                                                                        NEWS
 ?? ??? 2016 PHP 7.0.4
 
 - Core:
+  . Fixed bug #71442 (forward_static_call crash). (Laruence)
   . Fixed bug #71441 (Typehinted Generator with return in try/finally crashes).
     (Bob)
 
index ad9cf1ce2860efd2c9e30513d4e2409daa45bd35..9c657a3d09b7c8a4688aeb783c6bcbf63e570c71 100644 (file)
@@ -4835,7 +4835,7 @@ PHP_FUNCTION(forward_static_call)
        fci.retval = &retval;
 
        called_scope = zend_get_called_scope(execute_data);
-       if (called_scope &&
+       if (called_scope && fci_cache.calling_scope &&
                instanceof_function(called_scope, fci_cache.calling_scope)) {
                        fci_cache.called_scope = called_scope;
        }
@@ -4863,7 +4863,7 @@ PHP_FUNCTION(forward_static_call_array)
        fci.retval = &retval;
 
        called_scope = zend_get_called_scope(execute_data);
-       if (called_scope &&
+       if (called_scope && fci_cache.calling_scope &&
                instanceof_function(called_scope, fci_cache.calling_scope)) {
                        fci_cache.called_scope = called_scope;
        }
diff --git a/ext/standard/tests/class_object/bug71442.phpt b/ext/standard/tests/class_object/bug71442.phpt
new file mode 100644 (file)
index 0000000..d6b3d66
--- /dev/null
@@ -0,0 +1,37 @@
+--TEST--
+Bug #71442 (forward_static_call crash)
+--FILE--
+<?php
+
+class A
+{
+       const NAME = 'A';
+       public static function test() {
+               $args = func_get_args();
+               echo static::NAME, " ".join(',', $args)." \n";
+       }
+}
+
+class B extends A
+{
+       const NAME = 'B';
+
+       public static function test() {
+               echo self::NAME, "\n";
+               forward_static_call(array('A', 'test'), 'more', 'args');
+               forward_static_call( 'test', 'other', 'args');
+       }
+}
+
+B::test('foo');
+
+function test() {
+       $args = func_get_args();
+       echo "C ".join(',', $args)." \n";
+}
+
+?>
+--EXPECT--
+B
+B more,args 
+C other,args