Skip to content

ext/ldap: php_ldap_do_modify() attempts to free pointer not allocated by ZMM. #16132

Closed
@Girgias

Description

@Girgias

Description

The following code:

<?php

/* ldap_add(_ext)(), ldap_mod_replace(_ext)(), ldap_mod_add(_ext)(), and ldap_mod_del(_ext)() share an underlying C function */
/* We are assuming 3333 is not connectable */
$ldap = ldap_connect('ldap://127.0.0.1:3333');
$valid_dn = "cn=userA,something";

$dict_key_value_not_string = [
    'attribute1' => new stdClass(),
    'attribute2' => [
        'value1',
        'value2',
    ],
];
try {
    var_dump(ldap_add($ldap, $valid_dn, $dict_key_value_not_string));
} catch (Throwable $e) {
    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

Resulted in this output:

php: /home/girgias/Dev/PHP-8.2/Zend/zend_alloc.c:2809: tracked_get_size_zv: Assertion `size_zv && "Trying to free pointer not allocated through ZendMM"' failed.

Termsig=6

But I expected this output instead:

Exception to be caught

Moreover:

The following code:

<?php

/* ldap_add(_ext)(), ldap_mod_replace(_ext)(), ldap_mod_add(_ext)(), and ldap_mod_del(_ext)() share an underlying C function */
/* We are assuming 3333 is not connectable */
$ldap = ldap_connect('ldap://127.0.0.1:3333');
$valid_dn = "cn=userA,something";

$dict_key_multi_value_not_list_of_strings2 = [
    'attribute1' => 'value',
    'attribute2' => [
        'value1',
        new stdClass(),
    ],
];
try {
    var_dump(ldap_add($ldap, $valid_dn, $dict_key_multi_value_not_list_of_strings2));
} catch (Throwable $e) {
    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

Resulted in this output:

php: /home/girgias/Dev/PHP-8.2/Zend/zend_alloc.c:2809: tracked_get_size_zv: Assertion `size_zv && "Trying to free pointer not allocated through ZendMM"' failed.

Termsig=6

But I expected this output instead:

Exception to be caught

PHP Version

PHP 8.2

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions