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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
29 - 10 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 20:01:32 2024 UTC