From aa1431e53febdeb80d2c93f6e330fbaedb607ba3 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 25 Feb 2015 11:55:43 +0100 Subject: [PATCH] kdc-db-glue: Fix memory cleanup to avoid crashes. Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher --- source4/kdc/db-glue.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source4/kdc/db-glue.c b/source4/kdc/db-glue.c index 6bcfad5729c..7e955e74637 100644 --- a/source4/kdc/db-glue.c +++ b/source4/kdc/db-glue.c @@ -588,9 +588,9 @@ static krb5_error_code samba_kdc_message2entry(krb5_context context, is_computer = TRUE; } - memset(entry_ex, 0, sizeof(*entry_ex)); + ZERO_STRUCTP(entry_ex); - p = talloc(mem_ctx, struct samba_kdc_entry); + p = talloc_zero(mem_ctx, struct samba_kdc_entry); if (!p) { ret = ENOMEM; goto out; @@ -937,6 +937,7 @@ out: if (ret != 0) { /* This doesn't free ent itself, that is for the eventual caller to do */ hdb_free_entry(context, entry_ex); + ZERO_STRUCTP(entry_ex); } else { talloc_steal(kdc_db_ctx, entry_ex->ctx); }