php.net |  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: cmb@php.net 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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

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


Test script:
---------------
<?php
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 ===


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-30 16:13 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2019-10-30 16:23 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1e2d3d58a8b392385d926bdca11ba0a0bc2547b4
Log: Fix #78762: Failing FFI::cast() may leak memory
 [2019-10-30 16:23 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Nov 30 21:01:23 2020 UTC