1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-07 12:23:51 +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); krb5_clear_error_string (context);
return KRB5_KT_NOTFOUND; return KRB5_KT_NOTFOUND;
} }
e = realloc(d->entries, d->num_entries * sizeof(*d->entries)); if (d->num_entries == 0) {
if(e != NULL) free(d->entries);
d->entries = e; d->entries = NULL;
} else {
e = realloc(d->entries, d->num_entries * sizeof(*d->entries));
if(e != NULL)
d->entries = e;
}
return 0; return 0;
} }