Hello,

This patch fixes potential crash after free(uninitialized variable) in persistent search code.

Coverity CID 13088.

Petr^2 Spacek
From 3197b4ace3e852495bf4f9fdc32192459160027c Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Wed, 12 Sep 2012 13:04:39 +0200
Subject: [PATCH] Fix potential crash after free(uninitialized variable) in
 persistent search code.

Coverity CID 13088.

Signed-off-by: Petr Spacek <pspa...@redhat.com>
---
 src/ldap_helper.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/ldap_helper.c b/src/ldap_helper.c
index 92edbe7159272772e1c993d46da7c93382cbc5d4..67a64b79159983c83cb1bfc73c4b02a9bce986a7 100644
--- a/src/ldap_helper.c
+++ b/src/ldap_helper.c
@@ -2878,8 +2878,8 @@ cleanup:
 static isc_result_t
 ldap_pscontrol_create(LDAPControl **ctrlp)
 {
-	BerElement *ber;
-	struct berval *berval;
+	BerElement *ber = NULL;
+	struct berval *berval = NULL;
 	isc_result_t result = ISC_R_FAILURE;
 
 	REQUIRE(ctrlp != NULL && *ctrlp == NULL);
@@ -2905,14 +2905,13 @@ ldap_pscontrol_create(LDAPControl **ctrlp)
 			!= LDAP_SUCCESS)
 		goto cleanup;
 
-	ber_free(ber, 1);
-	ber_bvfree(berval);
-
-	return ISC_R_SUCCESS;
+	result = ISC_R_SUCCESS;
 
 cleanup:
-	ber_free(ber, 1);
-	ber_bvfree(berval);
+	if (ber != NULL)
+		ber_free(ber, 1);
+	if (berval != NULL)
+		ber_bvfree(berval);
 
 	return result;
 }
-- 
1.7.11.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to