php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80049 Memleak when coercing integers to string via variadic argument
Submitted: 2020-09-03 14:38 UTC Modified: 2020-09-03 15:09 UTC
From: sjon@php.net Assigned:
Status: Closed Package: *General Issues
PHP Version: 8.0.0beta3 OS: archLinux
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:
10 + 22 = ?
Subscribe to this entry?

 
 [2020-09-03 14:38 UTC] sjon@php.net
Description:
------------
I hope this fixes the majority of the 900 memleaks we currently have in our application

Test script:
---------------
class sa
{
    public static function coerceTo(string $type, array $array): array
    {
        return self::_coerceToString(...array_values($array));
    }

    protected static function _coerceToString(string ...$strings): array
    {
        return $strings;
    }
}

sa::coerceTo("string", ['nl' => 0.9, 'be' => 0.2]);


Actual result:
--------------
Zend/zend_string.h(141) :  Freeing 0x00007fb91a281300 (224 bytes), script=/tmp/memleak.php
Last leak repeated 1 time


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-03 14:45 UTC] nikic@php.net
Small additional reduction:

<?php
function coerceToString(string ...$strings) {
    var_dump($strings);
}
coerceToString(...[123]);
 [2020-09-03 15:09 UTC] nikic@php.net
-Summary: memleak when coercing integers to string +Summary: Memleak when coercing integers to string via variadic argument
 [2020-09-03 15:14 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=46a49be6c866103ebcb95e03b2b96460bec16b7b
Log: Fixed bug #80049
 [2020-09-03 15:14 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 05:01:28 2024 UTC