Skip to content

Commit e7f2c5b

Browse files
committed
Fixed bug #71442 (forward_static_call crash)
1 parent b68d525 commit e7f2c5b

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PHP NEWS
33
?? ??? 2016 PHP 7.0.4
44

55
- Core:
6+
. Fixed bug #71442 (forward_static_call crash). (Laruence)
67
. Fixed bug #71441 (Typehinted Generator with return in try/finally crashes).
78
(Bob)
89

ext/standard/basic_functions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4835,7 +4835,7 @@ PHP_FUNCTION(forward_static_call)
48354835
fci.retval = &retval;
48364836

48374837
called_scope = zend_get_called_scope(execute_data);
4838-
if (called_scope &&
4838+
if (called_scope && fci_cache.calling_scope &&
48394839
instanceof_function(called_scope, fci_cache.calling_scope)) {
48404840
fci_cache.called_scope = called_scope;
48414841
}
@@ -4863,7 +4863,7 @@ PHP_FUNCTION(forward_static_call_array)
48634863
fci.retval = &retval;
48644864

48654865
called_scope = zend_get_called_scope(execute_data);
4866-
if (called_scope &&
4866+
if (called_scope && fci_cache.calling_scope &&
48674867
instanceof_function(called_scope, fci_cache.calling_scope)) {
48684868
fci_cache.called_scope = called_scope;
48694869
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
Bug #71442 (forward_static_call crash)
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
const NAME = 'A';
9+
public static function test() {
10+
$args = func_get_args();
11+
echo static::NAME, " ".join(',', $args)." \n";
12+
}
13+
}
14+
15+
class B extends A
16+
{
17+
const NAME = 'B';
18+
19+
public static function test() {
20+
echo self::NAME, "\n";
21+
forward_static_call(array('A', 'test'), 'more', 'args');
22+
forward_static_call( 'test', 'other', 'args');
23+
}
24+
}
25+
26+
B::test('foo');
27+
28+
function test() {
29+
$args = func_get_args();
30+
echo "C ".join(',', $args)." \n";
31+
}
32+
33+
?>
34+
--EXPECT--
35+
B
36+
B more,args
37+
C other,args

0 commit comments

Comments
 (0)