summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/kdb/kdb5.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c
index 4dfe66151a..a3a0d6f49c 100644
--- a/src/lib/kdb/kdb5.c
+++ b/src/lib/kdb/kdb5.c
@@ -2048,16 +2048,14 @@ krb5_dbe_get_strings(krb5_context context, krb5_db_entry *entry,
while (next_attr(&pos, end, &mapkey, &mapval)) {
/* Add a copy of mapkey and mapvalue to strings. */
- key = strdup(mapkey);
- val = strdup(mapval);
newstrings = realloc(strings, (count + 1) * sizeof(*strings));
- if (key == NULL || val == NULL || newstrings == NULL) {
- free(key);
- free(val);
- krb5_dbe_free_strings(context, strings, count);
- return ENOMEM;
- }
+ if (newstrings == NULL)
+ goto oom;
strings = newstrings;
+ key = strdup(mapkey);
+ val = strdup(mapval);
+ if (key == NULL || val == NULL)
+ goto oom;
strings[count].key = key;
strings[count].value = val;
count++;
@@ -2066,6 +2064,12 @@ krb5_dbe_get_strings(krb5_context context, krb5_db_entry *entry,
*strings_out = strings;
*count_out = count;
return 0;
+
+oom:
+ free(key);
+ free(val);
+ krb5_dbe_free_strings(context, strings, count);
+ return ENOMEM;
}
krb5_error_code