php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79749 Object of class FFI could not be converted to bool in a simple if
Submitted: 2020-06-27 20:57 UTC Modified: 2020-06-29 11:41 UTC
From: kelunik@php.net Assigned:
Status: Closed Package: *Extensibility Functions
PHP Version: 8.0Git-2020-06-27 (Git) OS: Ubuntu
Private report: No CVE-ID: None
 [2020-06-27 20:57 UTC] kelunik@php.net
Description:
------------
This works on PHP 7.4 and also works on PHP 8 with other objects like new \stdClass.

Test script:
---------------
<?php
// create FFI object, loading libc and exporting function printf()
$ffi = FFI::cdef(
    "int printf(const char *format, ...);", // this is regular C declaration
    "libc.so.6");
// call C printf()
$ffi->printf("Hello %s!\n", "world");
if ($ffi) {
    print 'ok';
}



Expected result:
----------------
Hello world!
ok

Actual result:
--------------
Hello world!
PHP Recoverable fatal error:  Object of class FFI could not be converted to bool in /home/kelunik/test.php on line 8

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-28 05:27 UTC] kelunik@php.net
-Package: Scripting Engine problem +Package: ffi
 [2020-06-28 05:28 UTC] kelunik@php.net
-Package: ffi +Package: Scripting Engine problem
 [2020-06-29 11:41 UTC] cmb@php.net
-Status: Open +Status: Verified -Package: Scripting Engine problem +Package: *Extensibility Functions
 [2020-06-29 11:44 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #79749: Converting FFI instances to bool fails
On GitHub:  https://github.com/php/php-src/pull/5776
Patch:      https://github.com/php/php-src/pull/5776.patch
 [2020-06-29 14:03 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=aca621cf926cf86fd186395d3877fc63b65f3d16
Log: Fix #79749: Converting FFI instances to bool fails
 [2020-06-29 14:03 UTC] cmb@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC