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

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