]> granicus.if.org Git - php/commitdiff
plug minor memleak
authorAntony Dovgal <tony2001@php.net>
Wed, 16 Apr 2008 13:20:59 +0000 (13:20 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 16 Apr 2008 13:20:59 +0000 (13:20 +0000)
ext/ldap/ldap.c

index 0835537183a036eae1fa1e98bce2e0db4b451fe1..64aa016d6341cc61004c0e6280c9225267219315 100644 (file)
@@ -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);