Blame SOURCES/0019-Don-t-leak-our-partition-table-structures.patch

38ab4d
From dd81884dfa1cd0c2ba97bcb3c0b04a69b14f9b6e Mon Sep 17 00:00:00 2001
5fb29d
From: Peter Jones <pjones@redhat.com>
5fb29d
Date: Wed, 10 Sep 2014 17:03:23 -0400
38ab4d
Subject: [PATCH 19/31] Don't leak our partition table structures.
5fb29d
5fb29d
Covscan once more.
5fb29d
5fb29d
Signed-off-by: Peter Jones <pjones@redhat.com>
5fb29d
---
5fb29d
 src/lib/gpt.c | 10 ++++++++--
5fb29d
 1 file changed, 8 insertions(+), 2 deletions(-)
5fb29d
5fb29d
diff --git a/src/lib/gpt.c b/src/lib/gpt.c
5fb29d
index fc2acf3..8cb0e39 100644
5fb29d
--- a/src/lib/gpt.c
5fb29d
+++ b/src/lib/gpt.c
5fb29d
@@ -612,6 +612,7 @@ gpt_disk_get_partition_info(int fd,
5fb29d
 {
5fb29d
 	gpt_header *gpt = NULL;
5fb29d
 	gpt_entry *ptes = NULL, *p;
5fb29d
+	int rc = 0;
5fb29d
 
5fb29d
 	if (!find_valid_gpt(fd, &gpt, &ptes))
5fb29d
 		return 1;
5fb29d
@@ -628,9 +629,14 @@ gpt_disk_get_partition_info(int fd,
5fb29d
 		       sizeof (p->unique_partition_guid));
5fb29d
 	} else {
5fb29d
 		fprintf (stderr,"partition %d is not valid\n", num);
5fb29d
-		return 1;
5fb29d
+		rc = 1;
5fb29d
 	}
5fb29d
-	return 0;
5fb29d
+	if (ptes)
5fb29d
+		free(ptes);
5fb29d
+	if (gpt)
5fb29d
+		free(gpt);
5fb29d
+
5fb29d
+	return rc;
5fb29d
 }
5fb29d
 
5fb29d
 /*
5fb29d
-- 
38ab4d
2.7.4
5fb29d