Skip to content

Commit 2dd7745

Browse files
committed
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Fixed #75220 - Segfault when calling is_callable on parent
2 parents 0217a81 + a680d70 commit 2dd7745

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
- MySQLi:
1315
. Fixed bug #75018 (Data corruption when reading fields of bit type). (Anatol)

Zend/zend_API.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,7 +3068,8 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
30683068
(!fcc->function_handler->common.scope ||
30693069
!instanceof_function(ce_org, fcc->function_handler->common.scope))) {
30703070
if (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
3071-
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
3071+
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION &&
3072+
fcc->function_handler->common.function_name) {
30723073
zend_string_release(fcc->function_handler->common.function_name);
30733074
}
30743075
zend_free_trampoline(fcc->function_handler);
@@ -3240,7 +3241,8 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
32403241
((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) ||
32413242
fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
32423243
fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
3243-
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
3244+
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION &&
3245+
fcc->function_handler->common.function_name) {
32443246
zend_string_release(fcc->function_handler->common.function_name);
32453247
}
32463248
zend_free_trampoline(fcc->function_handler);
@@ -3327,7 +3329,8 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
33273329
((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) ||
33283330
fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY ||
33293331
fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) {
3330-
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) {
3332+
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION &&
3333+
fcc->function_handler->common.function_name) {
33313334
zend_string_release(fcc->function_handler->common.function_name);
33323335
}
33333336
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)