Skip to content

Commit a680d70

Browse files
andrewnesterkrakjoe
authored andcommitted
Fixed #75220 - Segfault when calling is_callable on parent
1 parent 3752d18 commit a680d70

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ PHP NEWS
88
. Fixed bug #75236 (infinite loop when printing an error-message). (Andrea)
99
. Fixed bug #75252 (Incorrect token formatting on two parse errors in one
1010
request). (Nikita)
11+
. Fixed bug #75220 (Segfault when calling is_callable on parent).
12+
(andrewnester)
1113

1214
- SPL:
1315
. Fixed bug #73629 (SplDoublyLinkedList::setIteratorMode masks intern flags).

Zend/zend_API.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,7 +3067,8 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
30673067
(!fcc->function_handler->common.scope ||
30683068
!instanceof_function(ce_org, fcc->function_handler->common.scope))) {
30693069
if (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
3070-
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
3070+
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION &&
3071+
fcc->function_handler->common.function_name) {
30713072
zend_string_release(fcc->function_handler->common.function_name);
30723073
}
30733074
zend_free_trampoline(fcc->function_handler);
@@ -3237,7 +3238,8 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
32373238
((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) ||
32383239
fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
32393240
fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
3240-
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
3241+
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION &&
3242+
fcc->function_handler->common.function_name) {
32413243
zend_string_release(fcc->function_handler->common.function_name);
32423244
}
32433245
zend_free_trampoline(fcc->function_handler);
@@ -3324,7 +3326,8 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
33243326
((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) ||
33253327
fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
33263328
fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
3327-
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
3329+
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION &&
3330+
fcc->function_handler->common.function_name) {
33283331
zend_string_release(fcc->function_handler->common.function_name);
33293332
}
33303333
zend_free_trampoline(fcc->function_handler);

ext/standard/tests/bug75220.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Bug #75220 (is_callable crash for 'parent')
3+
--FILE--
4+
<?php
5+
6+
$a = new A();
7+
$a->bar('foo');
8+
9+
class B {};
10+
class A extends B
11+
{
12+
function bar($func)
13+
{
14+
var_dump('foo');
15+
var_dump(is_callable('parent::foo'));
16+
var_dump(is_callable(array('parent', 'foo')));
17+
}
18+
19+
function __call($func, $args)
20+
{
21+
}
22+
};
23+
24+
?>
25+
--EXPECT--
26+
string(3) "foo"
27+
bool(false)
28+
bool(false)

0 commit comments

Comments
 (0)