|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78762 Failing FFI::cast() may leak memory
Submitted: 2019-10-30 16:13 UTC Modified: 2019-10-30 16:13 UTC
From: Assigned: cmb (profile)
Status: Closed Package: *Extensibility Functions
PHP Version: 7.4Git-2019-10-30 (Git) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2019-10-30 16:13 UTC]
If FFI::cast() fails with FFI\Exception "attempt to cast to larger
type", a zend_ffi_cdata struct is leaked.

Test script:
try {
    FFI::cast('char[10]', FFI::new('char[1]'));
} catch (FFI\Exception $ex) {
    echo $ex->getMessage(), PHP_EOL;

Expected result:
attempt to cast to larger type

Actual result:
attempt to cast to larger type
[Wed Oct 30 17:10:23 2019]  Script:  '/mnt/d/git/php/bug78761.php'
/mnt/d/git/php/php-src/ext/ffi/ffi.c(241) :  Freeing 0x00007f0f67081180 (88 bytes), script=/mnt/d/git/php/bug78761.php
=== Total 1 memory leaks detected ===


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-30 16:13 UTC]
-Assigned To: +Assigned To: cmb
 [2019-10-30 16:23 UTC]
Automatic comment on behalf of
Log: Fix #78762: Failing FFI::cast() may leak memory
 [2019-10-30 16:23 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Nov 30 21:01:23 2020 UTC