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