1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-01 16:23:49 +03:00

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 commit is contained in:
Andrew Bartlett
2005-12-03 00:47:51 +00:00
committed by Gerald (Jerry) Carter
parent 0c4ea6f641
commit d5a2de8ef0

View File

@@ -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;
}