From 8d130005a1d124d6d534a36be9de79e988c63e14 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 23 May 2006 05:14:06 +0000 Subject: r15830: fixed two kdc memory leaks (This used to be commit cc290ece92196d2bdf39eaa9d3bb4a0af6ec782c) --- source4/kdc/hdb-ldb.c | 20 +++++++------------- source4/kdc/kdc.c | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/source4/kdc/hdb-ldb.c b/source4/kdc/hdb-ldb.c index c1ed262f7d..cc354af9e9 100644 --- a/source4/kdc/hdb-ldb.c +++ b/source4/kdc/hdb-ldb.c @@ -799,27 +799,21 @@ static krb5_error_code LDB_fetch(krb5_context context, HDB *db, if (flags & HDB_F_GET_CLIENT) { ret = LDB_fetch_client(context, db, mem_ctx, principal, flags, entry_ex); - if (ret != HDB_ERR_NOENTRY) { - talloc_free(mem_ctx); - return ret; - } + if (ret != HDB_ERR_NOENTRY) goto done; } if (flags & HDB_F_GET_SERVER) { ret = LDB_fetch_server(context, db, mem_ctx, principal, flags, entry_ex); - if (ret != HDB_ERR_NOENTRY) { - return ret; - } + if (ret != HDB_ERR_NOENTRY) goto done; ret = LDB_fetch_krbtgt(context, db, mem_ctx, principal, flags, entry_ex); - if (ret != HDB_ERR_NOENTRY) { - return ret; - } + if (ret != HDB_ERR_NOENTRY) goto done; } if (flags & HDB_F_GET_KRBTGT) { ret = LDB_fetch_krbtgt(context, db, mem_ctx, principal, flags, entry_ex); - if (ret != HDB_ERR_NOENTRY) { - return ret; - } + if (ret != HDB_ERR_NOENTRY) goto done; } + +done: + talloc_free(mem_ctx); return ret; } diff --git a/source4/kdc/kdc.c b/source4/kdc/kdc.c index 4ce17a8718..10e0764e23 100644 --- a/source4/kdc/kdc.c +++ b/source4/kdc/kdc.c @@ -127,7 +127,7 @@ static void kdc_recv_handler(struct kdc_socket *kdc_socket) return; } - blob = data_blob_talloc(kdc_socket, NULL, dsize); + blob = data_blob_talloc(tmp_ctx, NULL, dsize); if (blob.data == NULL) { /* hope this is a temporary low memory condition */ talloc_free(tmp_ctx); -- cgit