diff --git a/lib/krb5/config_file.c b/lib/krb5/config_file.c index 44d441fdd..3c0b0a447 100644 --- a/lib/krb5/config_file.c +++ b/lib/krb5/config_file.c @@ -934,13 +934,17 @@ krb5_config_vget_strings(krb5_context context, s = next_component_string(tmp, " \t", &pos); while(s){ char **tmp2 = realloc(strings, (nstr + 1) * sizeof(*strings)); - if(tmp2 == NULL) + if(tmp2 == NULL) { + free(tmp); goto cleanup; + } strings = tmp2; strings[nstr] = strdup(s); nstr++; - if(strings[nstr-1] == NULL) + if(strings[nstr-1] == NULL) { + free(tmp); goto cleanup; + } s = next_component_string(NULL, " \t", &pos); } free(tmp);