Blame SOURCES/0001-libsemanage-Fix-RESOURCE_LEAK-and-USE_AFTER_FREE-cov.patch

5eb2a8
From dc105dcb5e34e256bcbcf547fea590cfcee06933 Mon Sep 17 00:00:00 2001
5eb2a8
From: Petr Lautrbach <plautrba@redhat.com>
5eb2a8
Date: Wed, 7 Nov 2018 18:17:34 +0100
5eb2a8
Subject: [PATCH] libsemanage: Fix RESOURCE_LEAK and USE_AFTER_FREE coverity
5eb2a8
 scan defects
5eb2a8
5eb2a8
---
5eb2a8
 libsemanage/src/direct_api.c | 21 ++++++++-------------
5eb2a8
 1 file changed, 8 insertions(+), 13 deletions(-)
5eb2a8
5eb2a8
diff --git a/libsemanage/src/direct_api.c b/libsemanage/src/direct_api.c
5eb2a8
index c58961be..8e4d116d 100644
5eb2a8
--- a/libsemanage/src/direct_api.c
5eb2a8
+++ b/libsemanage/src/direct_api.c
5eb2a8
@@ -1028,7 +1028,7 @@ static int semanage_direct_write_langext(semanage_handle_t *sh,
5eb2a8
 
5eb2a8
 	fp = NULL;
5eb2a8
 
5eb2a8
-	ret = 0;
5eb2a8
+	return 0;
5eb2a8
 
5eb2a8
 cleanup:
5eb2a8
 	if (fp != NULL) fclose(fp);
5eb2a8
@@ -2177,7 +2177,6 @@ cleanup:
5eb2a8
 	semanage_module_info_destroy(sh, modinfo);
5eb2a8
 	free(modinfo);
5eb2a8
 
5eb2a8
-	if (fp != NULL) fclose(fp);
5eb2a8
 	return status;
5eb2a8
 }
5eb2a8
 
5eb2a8
@@ -2342,16 +2341,6 @@ static int semanage_direct_get_module_info(semanage_handle_t *sh,
5eb2a8
 	free(tmp);
5eb2a8
 	tmp = NULL;
5eb2a8
 
5eb2a8
-	if (fclose(fp) != 0) {
5eb2a8
-		ERR(sh,
5eb2a8
-		    "Unable to close %s module lang ext file.",
5eb2a8
-		    (*modinfo)->name);
5eb2a8
-		status = -1;
5eb2a8
-		goto cleanup;
5eb2a8
-	}
5eb2a8
-
5eb2a8
-	fp = NULL;
5eb2a8
-
5eb2a8
 	/* lookup enabled/disabled status */
5eb2a8
 	ret = semanage_module_get_path(sh,
5eb2a8
 				       *modinfo,
5eb2a8
@@ -2395,7 +2384,13 @@ cleanup:
5eb2a8
 		free(modinfos);
5eb2a8
 	}
5eb2a8
 
5eb2a8
-	if (fp != NULL) fclose(fp);
5eb2a8
+	if (fp != NULL && fclose(fp) != 0) {
5eb2a8
+		ERR(sh,
5eb2a8
+		    "Unable to close %s module lang ext file.",
5eb2a8
+		    (*modinfo)->name);
5eb2a8
+		status = -1;
5eb2a8
+	}
5eb2a8
+
5eb2a8
 	return status;
5eb2a8
 }
5eb2a8
 
5eb2a8
-- 
5eb2a8
2.21.0
5eb2a8