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

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