Skip to content

Commit d6ef63d

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #78543: is_callable() on FFI\CData throws Exception
2 parents f816171 + 9dfbcd7 commit d6ef63d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Zend/zend_API.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3230,12 +3230,18 @@ static zend_always_inline zend_bool zend_is_callable_impl(zval *callable, zend_o
32303230
}
32313231
return 0;
32323232
case IS_OBJECT:
3233-
if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(Z_OBJ_P(callable), &fcc->calling_scope, &fcc->function_handler, &fcc->object) == SUCCESS) {
3233+
if (Z_OBJ_HANDLER_P(callable, get_closure)) {
3234+
if (Z_OBJ_HANDLER_P(callable, get_closure)(Z_OBJ_P(callable), &fcc->calling_scope, &fcc->function_handler, &fcc->object) == SUCCESS) {
32343235
fcc->called_scope = fcc->calling_scope;
32353236
if (fcc == &fcc_local) {
32363237
zend_release_fcall_info_cache(fcc);
32373238
}
32383239
return 1;
3240+
} else {
3241+
/* Discard exceptions thrown from Z_OBJ_HANDLER_P(callable, get_closure)
3242+
TODO: extend get_closure() with additional argument and prevent exception throwing in the first place */
3243+
zend_clear_exception();
3244+
}
32393245
}
32403246
if (error) *error = estrdup("no array or string given");
32413247
return 0;

ext/ffi/tests/bug78543.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #78543 (is_callable() on FFI\CData throws Exception)
3+
--SKIPIF--
4+
<?php require_once('skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
$ffi = FFI::cdef(' struct test { int dummy; }; ');
8+
$test = $ffi->new('struct test');
9+
var_dump(is_callable($test));
10+
?>
11+
--EXPECT--
12+
bool(false)

0 commit comments

Comments
 (0)