Skip to content

Memory leak __call magic method with named parameters #12835

Closed
@matyhtf

Description

@matyhtf

Description

The following code:

ZEND_METHOD(MyObject, __call) {
    char *name;
    size_t l_name;
    zval *arguments;

    ZEND_PARSE_PARAMETERS_START(2, 2)
    Z_PARAM_STRING(name, l_name)
    Z_PARAM_ARRAY(arguments)
    ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
}
$obj = new MyObject;

$obj->test('a', 'b', name: 'hello');

No memory leaks when not using named parameters.

$obj = new MyObject;

$obj->test('a', 'b');

Resulted in this output:

[Thu Nov 30 19:40:54 2023]  Script:  '/home/htf/workspace/python-php/main.php'
/home/htf/soft/php-8.1.23/Zend/zend_hash.c(281) :  Freeing 0x00007ff473b10000 (56 bytes), script=/home/htf/workspace/main.php
Last leak repeated 4 times
[Thu Nov 30 19:40:54 2023]  Script:  'script=/home/htf/workspace/main.php'
Zend/zend_string.h(152) :  Freeing 0x00007ff473b11000 (224 bytes), script=/home/htf/workspace/main.php
Last leak repeated 4 times
[Thu Nov 30 19:40:54 2023]  Script:  '/home/htf/workspace/main.php'
/home/htf/soft/php-8.1.23/Zend/zend_hash.c(174) :  Freeing 0x00007ff473be7980 (320 bytes), script=/home/htf/workspace/main.php
Last leak repeated 4 times
=== Total 15 memory leaks detected ===

But I expected this output instead:

no memory leak

PHP Version

PHP 8.1.23

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions