summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2019-09-19 09:17:53 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2019-09-19 09:17:53 +0200
commitd6ef63db53383ad8ad1b61fb5283e836a1688a4c (patch)
treebcfa6de8c5022d472ebbe404f61b00a15b7e7ca1
parentf816171240d10ef15c7d4742b67486d33d017065 (diff)
parent9dfbcd7248012ac651a48eb871bfa58bb9e6c5d7 (diff)
downloadphp-git-d6ef63db53383ad8ad1b61fb5283e836a1688a4c.tar.gz
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #78543: is_callable() on FFI\CData throws Exception
-rw-r--r--Zend/zend_API.c8
-rw-r--r--ext/ffi/tests/bug78543.phpt12
2 files changed, 19 insertions, 1 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 1ace606a7e..ad61ad6624 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 0000000000..e2f014d7fc
--- /dev/null
+++ b/ext/ffi/tests/bug78543.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #78543 (is_callable() on FFI\CData throws Exception)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$ffi = FFI::cdef(' struct test { int dummy; }; ');
+$test = $ffi->new('struct test');
+var_dump(is_callable($test));
+?>
+--EXPECT--
+bool(false)