Found a couple of memleaks while reviewing code.

Attached.

Simo.

-- 
Simo Sorce * Red Hat, Inc * New York
>From 70840691e48e1ac89002499c08a9dd4fdcae7c50 Mon Sep 17 00:00:00 2001
From: Simo Sorce <[email protected]>
Date: Sun, 20 Nov 2011 20:50:11 -0500
Subject: [PATCH] ipa-kdb: fix memleaks in ipa_kdb_mspac.c

---
 daemons/ipa-kdb/ipa_kdb_mspac.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/daemons/ipa-kdb/ipa_kdb_mspac.c b/daemons/ipa-kdb/ipa_kdb_mspac.c
index cce1ca9060f0e03d525bb87d843bdd5811e9d20b..0c0da75ca8dbedf12e39e8ec5d87bfd4cd485d4a 100644
--- a/daemons/ipa-kdb/ipa_kdb_mspac.c
+++ b/daemons/ipa-kdb/ipa_kdb_mspac.c
@@ -466,7 +466,7 @@ static krb5_error_code ipadb_get_pac(krb5_context kcontext,
     TALLOC_CTX *tmpctx;
     struct ipadb_e_data *ied;
     struct ipadb_context *ipactx;
-    LDAPMessage *results;
+    LDAPMessage *results = NULL;
     LDAPMessage *lentry;
     DATA_BLOB pac_data;
     krb5_data data;
@@ -479,11 +479,6 @@ static krb5_error_code ipadb_get_pac(krb5_context kcontext,
         return KRB5_KDB_DBNOTINITED;
     }
 
-    tmpctx = talloc_new(NULL);
-    if (!tmpctx) {
-        return ENOMEM;
-    }
-
     ied = (struct ipadb_e_data *)client->e_data;
     if (ied->magic != IPA_E_DATA_MAGIC) {
         return EINVAL;
@@ -493,6 +488,11 @@ static krb5_error_code ipadb_get_pac(krb5_context kcontext,
         return 0;
     }
 
+    tmpctx = talloc_new(NULL);
+    if (!tmpctx) {
+        return ENOMEM;
+    }
+
     memset(&pac_info, 0, sizeof(pac_info));
     pac_info.logon_info.info = talloc_zero(tmpctx, struct PAC_LOGON_INFO);
     if (!tmpctx) {
@@ -542,6 +542,7 @@ static krb5_error_code ipadb_get_pac(krb5_context kcontext,
     kerr = krb5_pac_add_buffer(kcontext, *pac, KRB5_PAC_LOGON_INFO, &data);
 
 done:
+    ldap_msgfree(results);
     talloc_free(tmpctx);
     return kerr;
 }
-- 
1.7.7.1

_______________________________________________
Freeipa-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to