Commit 878d489e authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Do not overwrite charray argument if charray_add realloc fails.

Caller is required to call ldap_charray_free as needed.
parent 93c7bccd
......@@ -24,17 +24,27 @@ ldap_charray_add(
if ( *a == NULL ) {
*a = (char **) LDAP_MALLOC( 2 * sizeof(char *) );
n = 0;
if( *a == NULL ) {
return -1;
}
} else {
char **new;
for ( n = 0; *a != NULL && (*a)[n] != NULL; n++ ) {
; /* NULL */
}
*a = (char **) LDAP_REALLOC( (char *) *a,
new = (char **) LDAP_REALLOC( (char *) *a,
(n + 2) * sizeof(char *) );
}
if( *a == NULL ) {
return -1;
if( new == NULL ) {
/* caller is required to call ldap_charray_free(*a) */
return -1;
}
*a = new;
}
(*a)[n] = LDAP_STRDUP(s);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment