andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From 14b2dda6574c3358df4a5770de78eb96504200cd Mon Sep 17 00:00:00 2001
dc8c34
From: Noriko Hosoi <nhosoi@redhat.com>
dc8c34
Date: Mon, 10 Mar 2014 12:50:57 -0700
dc8c34
Subject: [PATCH 185/225] Ticket #47740 - Coverity issue in 1.3.3
dc8c34
dc8c34
Description: Coverity 11778 - Resource leak
dc8c34
val was allocated by dbconf_decodeval, which was not freed if propval
dc8c34
failed to create.
dc8c34
dc8c34
Reviewed by mareynol@redhat.com (Thanks, Mark!)
dc8c34
(cherry picked from commit 6f51e06c606049e7ca8e0b763c683fa98b33974a)
dc8c34
(cherry picked from commit f3afc1198c2d9d63d6b5ad01d3fe5b9061d648a1)
dc8c34
(cherry picked from commit cfb821cf44eee3fd977702e6a81267bac1f3625f)
dc8c34
(cherry picked from commit d8395ecd432fd68588992a954113bca23e48e99f)
dc8c34
---
dc8c34
 lib/ldaputil/dbconf.c | 10 +++++-----
dc8c34
 1 file changed, 5 insertions(+), 5 deletions(-)
dc8c34
dc8c34
diff --git a/lib/ldaputil/dbconf.c b/lib/ldaputil/dbconf.c
dc8c34
index e6de3b7..1ffdab7 100644
dc8c34
--- a/lib/ldaputil/dbconf.c
dc8c34
+++ b/lib/ldaputil/dbconf.c
dc8c34
@@ -264,20 +264,20 @@ static int dbconf_parse_propval (char *buf, char *ptr,
dc8c34
     propval = (DBPropVal_t *)malloc(sizeof(DBPropVal_t));
dc8c34
 
dc8c34
     if (!propval){
dc8c34
-    	if (encval) free(val);
dc8c34
+        if (encval && val) free(val);
dc8c34
         return LDAPU_ERR_OUT_OF_MEMORY;
dc8c34
     }
dc8c34
     memset((void *)propval, 0, sizeof(DBPropVal_t));
dc8c34
     propval->prop = strdup(prop);
dc8c34
     propval->val = val ? strdup(val) : 0;
dc8c34
 
dc8c34
+    if (encval && val) free(val); /* val was allocated by dbconf_decodeval */
dc8c34
+
dc8c34
     if (!propval->prop || (val && !propval->val)) {
dc8c34
-	dbconf_free_propval(propval);
dc8c34
-	return LDAPU_ERR_OUT_OF_MEMORY;
dc8c34
+        dbconf_free_propval(propval);
dc8c34
+        return LDAPU_ERR_OUT_OF_MEMORY;
dc8c34
     }
dc8c34
 
dc8c34
-    if(encval) free(val);	/* val was allocated by dbconf_decodeval */
dc8c34
-
dc8c34
     insert_dbinfo_propval(db_info, propval);
dc8c34
     return LDAPU_SUCCESS;
dc8c34
 }
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34