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

5fb29d
From 38fa9b2ceb1095c320ee2aa7482a85fc91ec590d Mon Sep 17 00:00:00 2001
5fb29d
From: Peter Jones <pjones@redhat.com>
5fb29d
Date: Wed, 10 Sep 2014 17:03:23 -0400
5fb29d
Subject: [PATCH 18/18] 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
-- 
5fb29d
1.9.3
5fb29d