diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 1ace606a7e4..ad61ad66249 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3230,12 +3230,18 @@ check_func: } return 0; case IS_OBJECT: - 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) { + if (Z_OBJ_HANDLER_P(callable, get_closure)) { + if (Z_OBJ_HANDLER_P(callable, get_closure)(Z_OBJ_P(callable), &fcc->calling_scope, &fcc->function_handler, &fcc->object) == SUCCESS) { fcc->called_scope = fcc->calling_scope; if (fcc == &fcc_local) { zend_release_fcall_info_cache(fcc); } return 1; + } else { + /* Discard exceptions thrown from Z_OBJ_HANDLER_P(callable, get_closure) + TODO: extend get_closure() with additional argument and prevent exception throwing in the first place */ + zend_clear_exception(); + } } if (error) *error = estrdup("no array or string given"); return 0; diff --git a/ext/ffi/tests/bug78543.phpt b/ext/ffi/tests/bug78543.phpt new file mode 100644 index 00000000000..e2f014d7fc9 --- /dev/null +++ b/ext/ffi/tests/bug78543.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #78543 (is_callable() on FFI\CData throws Exception) +--SKIPIF-- + +--FILE-- +new('struct test'); +var_dump(is_callable($test)); +?> +--EXPECT-- +bool(false)