summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/heimdal/lib/krb5/keytab_memory.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/source4/heimdal/lib/krb5/keytab_memory.c b/source4/heimdal/lib/krb5/keytab_memory.c
index afa8f433ac..1039847de9 100644
--- a/source4/heimdal/lib/krb5/keytab_memory.c
+++ b/source4/heimdal/lib/krb5/keytab_memory.c
@@ -214,9 +214,15 @@ mkt_remove_entry(krb5_context context,
krb5_clear_error_string (context);
return KRB5_KT_NOTFOUND;
}
- e = realloc(d->entries, d->num_entries * sizeof(*d->entries));
- if(e != NULL)
- d->entries = e;
+ if (d->num_entries == 0) {
+ free(d->entries);
+ d->entries = NULL;
+ } else {
+ e = realloc(d->entries, d->num_entries * sizeof(*d->entries));
+ if(e != NULL)
+ d->entries = e;
+ }
+
return 0;
}