Skip to content

Commit c989a36

Browse files
committed
Fixed bug #54910 (Crash when calling call_user_func with unknown function name)
1 parent 3d7a201 commit c989a36

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ PHP NEWS
66
- Increased the backtrack limit from 100000 to 1000000 (Rasmus)
77

88
- Zend Engine:
9+
. Fixed bug #54910 (Crash when calling call_user_func with unknown function
10+
name). (Dmitry)
911
. Fixed bug #54804 (__halt_compiler and imported namespaces).
1012
(Pierrick, Felipe)
1113
. Fixed bug #54585 (track_errors causes segfault). (Dmitry)

Zend/tests/bug54910.phpt

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Bug #54910 (Crash when calling call_user_func with unknown function name)
3+
--FILE--
4+
<?php
5+
class A {
6+
public function __call($method, $args) {
7+
if (stripos($method, 'get') === 0) {
8+
return $this->get();
9+
}
10+
die("No such method - '$method'\n");
11+
}
12+
13+
protected function get() {
14+
$class = get_class($this);
15+
$call = array($class, 'noSuchMethod');
16+
17+
if (is_callable($call)) {
18+
call_user_func($call);
19+
}
20+
}
21+
}
22+
23+
class B extends A {}
24+
25+
$input = new B();
26+
echo $input->getEmail();
27+
--EXPECT--
28+
No such method - 'noSuchMethod'

Zend/zend_API.c

+5
Original file line numberDiff line numberDiff line change
@@ -2590,6 +2590,11 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
25902590
if (fcc->function_handler) {
25912591
retval = 1;
25922592
call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0;
2593+
if (call_via_handler && !fcc->object_ptr && EG(This) &&
2594+
Z_OBJ_HT_P(EG(This))->get_class_entry &&
2595+
instanceof_function(Z_OBJCE_P(EG(This)), fcc->calling_scope TSRMLS_CC)) {
2596+
fcc->object_ptr = EG(This);
2597+
}
25932598
}
25942599
}
25952600
}

0 commit comments

Comments
 (0)