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
 [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-2020 The PHP Group
All rights reserved.
Last updated: Wed Oct 21 06:01:23 2020 UTC