From 00e406ec415282d03d4fec7cde3736e889afcfb7 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Wed, 16 Apr 2008 13:20:59 +0000 Subject: [PATCH] plug minor memleak --- ext/ldap/ldap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index 0835537183..64aa016d63 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -1425,6 +1425,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper) for (i = 0; i < num_attribs; i++) { ldap_mods[i] = emalloc(sizeof(LDAPMod)); ldap_mods[i]->mod_op = oper | LDAP_MOD_BVALUES; + ldap_mods[i]->mod_type = NULL; if (zend_hash_get_current_key(Z_ARRVAL_PP(entry), &attribute, &index, 0) == HASH_KEY_IS_STRING) { ldap_mods[i]->mod_type = estrdup(attribute); @@ -1432,7 +1433,11 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown attribute in the data"); /* Free allocated memory */ while (i >= 0) { - efree(ldap_mods[i--]); + if (ldap_mods[i]->mod_type) { + efree(ldap_mods[i]->mod_type); + } + efree(ldap_mods[i]); + i--; } efree(num_berval); efree(ldap_mods); -- 2.40.0