Skip to content

Commit f604878

Browse files
committed
ext/ldap: Remove an unnecessary duplication
1 parent 636b6a1 commit f604878

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/ldap/ldap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,7 +2254,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext)
22542254
}
22552255
/* end additional , gerrit thomson */
22562256

2257-
const zend_string *attribute = NULL;
2257+
zend_string *attribute = NULL;
22582258
zval *attribute_values = NULL;
22592259
unsigned int attribute_index = 0;
22602260
ZEND_HASH_FOREACH_STR_KEY_VAL(attributes_ht, attribute, attribute_values) {
@@ -2276,7 +2276,8 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext)
22762276

22772277
ldap_mods[attribute_index] = emalloc(sizeof(LDAPMod));
22782278
ldap_mods[attribute_index]->mod_op = oper | LDAP_MOD_BVALUES;
2279-
ldap_mods[attribute_index]->mod_type = estrndup(ZSTR_VAL(attribute), ZSTR_LEN(attribute));
2279+
/* No need to duplicate the string as it is not consumed and the zend_string will not be released */
2280+
ldap_mods[attribute_index]->mod_type = ZSTR_VAL(attribute);
22802281
ldap_mods[attribute_index]->mod_bvalues = NULL;
22812282

22822283
ZVAL_DEREF(attribute_values);
@@ -2392,7 +2393,6 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext)
23922393
cleanup:
23932394
for (LDAPMod **ptr = ldap_mods; *ptr != NULL; ptr++) {
23942395
LDAPMod *mod = *ptr;
2395-
efree(mod->mod_type);
23962396
if (mod->mod_bvalues != NULL) {
23972397
for (struct berval **bval_ptr = mod->mod_bvalues; *bval_ptr != NULL; bval_ptr++) {
23982398
struct berval *bval = *bval_ptr;

0 commit comments

Comments
 (0)