summaryrefslogtreecommitdiff
path: root/source4/heimdal
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-12-03 00:47:51 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:01 -0500
commit9afdb938cd5e3c86d72d7ef8c5a8fced13291c9c (patch)
tree7486ecd60c5fc022e137a646a26a6e95ec7f974b /source4/heimdal
parentc85779b3b556c712f8fdcde6e2464bc2833054dd (diff)
downloadsamba-9afdb938cd5e3c86d72d7ef8c5a8fced13291c9c.tar.gz
samba-9afdb938cd5e3c86d72d7ef8c5a8fced13291c9c.tar.bz2
samba-9afdb938cd5e3c86d72d7ef8c5a8fced13291c9c.zip
r12037: Fix malloc corruption caused by double-free(), where realloc(ptr, 0)
is equivilant to free(). This is the issue tridge was seeing in the MEMORY: keytab code. Andrew Bartlett (This used to be commit d5a2de8ef06a08274d25ab005f2a68ec32e226f0)
Diffstat (limited to 'source4/heimdal')
-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;
}