mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix #79749: Converting FFI instances to bool fails
Casting objects to bool is supposed to yield `true`. Since the `cast_object` handler is required now, we have to implement the `_IS_BOOL` conversion there.
This commit is contained in:
parent
6e1990dea6
commit
aca621cf92
3 changed files with 33 additions and 2 deletions
7
NEWS
7
NEWS
|
@ -1,6 +1,11 @@
|
|||
PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? ????, PHP 8.0.0alpha1
|
||||
?? ??? ????, PHP 8.0.0alpha2
|
||||
|
||||
- FFI:
|
||||
. Fixed bug #79749 (Converting FFI instances to bool fails). (cmb)
|
||||
|
||||
25 Jun 2020, PHP 8.0.0alpha1
|
||||
|
||||
- Core:
|
||||
. Removed the pdo_odbc.db2_instance_name php.ini directive. (Kalle)
|
||||
|
|
|
@ -1096,6 +1096,9 @@ again:
|
|||
}
|
||||
convert_to_string(writeobj);
|
||||
return SUCCESS;
|
||||
} else if (type == _IS_BOOL) {
|
||||
ZVAL_TRUE(writeobj);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
return FAILURE;
|
||||
|
@ -4642,7 +4645,13 @@ static HashTable *zend_fake_get_gc(zend_object *ob, zval **table, int *n) /* {{{
|
|||
|
||||
static int zend_fake_cast_object(zend_object *obj, zval *result, int type)
|
||||
{
|
||||
return FAILURE;
|
||||
switch (type) {
|
||||
case _IS_BOOL:
|
||||
ZVAL_TRUE(result);
|
||||
return SUCCESS;
|
||||
default:
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
static ZEND_COLD zend_never_inline void zend_ffi_use_after_free(void) /* {{{ */
|
||||
|
|
17
ext/ffi/tests/bug79749.phpt
Normal file
17
ext/ffi/tests/bug79749.phpt
Normal file
|
@ -0,0 +1,17 @@
|
|||
--TEST--
|
||||
Bug #79749 (Converting FFI instances to bool fails)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('ffi')) die('skip ffi extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$ffi = FFI::cdef('typedef int dummy;');
|
||||
var_dump((bool) $ffi);
|
||||
var_dump((bool) FFI::type('int'));
|
||||
var_dump((bool) FFI::new('int'));
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
Loading…
Add table
Add a link
Reference in a new issue