mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix #78543: is_callable() on FFI\CData throws Exception
If `Z_OBJ_HANDLER_P(callable, get_closure)` throws, we must not let the exeception pass to userland, if called through `is_callable()`.
This commit is contained in:
parent
38ae522440
commit
9dfbcd7248
3 changed files with 24 additions and 5 deletions
2
NEWS
2
NEWS
|
@ -2,6 +2,8 @@ PHP NEWS
|
|||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? ????, PHP 7.4.0RC3
|
||||
|
||||
- FFI:
|
||||
. Fixed bug #78543 (is_callable() on FFI\CData throws Exception). (cmb)
|
||||
|
||||
19 Sep 2019, PHP 7.4.0RC2
|
||||
|
||||
|
|
|
@ -3411,12 +3411,17 @@ check_func:
|
|||
}
|
||||
return 0;
|
||||
case IS_OBJECT:
|
||||
if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(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);
|
||||
if (Z_OBJ_HANDLER_P(callable, get_closure)) {
|
||||
if (Z_OBJ_HANDLER_P(callable, get_closure)(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) */
|
||||
zend_clear_exception();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (error) *error = estrdup("no array or string given");
|
||||
return 0;
|
||||
|
|
12
ext/ffi/tests/bug78543.phpt
Normal file
12
ext/ffi/tests/bug78543.phpt
Normal file
|
@ -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)
|
Loading…
Add table
Add a link
Reference in a new issue