Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ext/ffi/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,9 @@ static int zend_ffi_cdata_cast_object(zend_object *readobj, zval *writeobj, int
}
convert_to_string(writeobj);
return SUCCESS;
} else if (type == _IS_BOOL) {
ZVAL_TRUE(writeobj);
return SUCCESS;
}

return FAILURE;
Expand Down Expand Up @@ -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) /* {{{ */
Expand Down
17 changes: 17 additions & 0 deletions ext/ffi/tests/bug79749.phpt
Original file line number Diff line number Diff line change
@@ -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)