Blame SOURCES/0005-Fix-some-minor-memory-leaks.patch

5fb29d
From 9b5950b9c6dd2322dadf2f54ecbbd24eddede278 Mon Sep 17 00:00:00 2001
5fb29d
From: Peter Jones <pjones@redhat.com>
5fb29d
Date: Wed, 10 Sep 2014 15:40:29 -0400
5fb29d
Subject: [PATCH 05/18] Fix some minor memory leaks.
5fb29d
5fb29d
Well, one and not really another.  Covscan is /almost/ a great tool.
5fb29d
5fb29d
Signed-off-by: Peter Jones <pjones@redhat.com>
5fb29d
---
5fb29d
 src/efibootmgr/efibootmgr.c | 10 ++++++++--
5fb29d
 1 file changed, 8 insertions(+), 2 deletions(-)
5fb29d
5fb29d
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
5fb29d
index 1c65c07..88a4ef7 100644
5fb29d
--- a/src/efibootmgr/efibootmgr.c
5fb29d
+++ b/src/efibootmgr/efibootmgr.c
5fb29d
@@ -627,8 +627,11 @@ construct_boot_order(char *bootorder, int keep,
5fb29d
 	size_t data_size = 0;
5fb29d
 
5fb29d
 	rc = parse_boot_order(bootorder, (uint16_t **)&data, &data_size);
5fb29d
-	if (rc < 0 || data_size == 0)
5fb29d
+	if (rc < 0 || data_size == 0) {
5fb29d
+		if (data) /* this can't actually happen, but covscan believes */
5fb29d
+			free(data);
5fb29d
 		return rc;
5fb29d
+	}
5fb29d
 
5fb29d
 	if (!keep) {
5fb29d
 		*ret_data = data;
5fb29d
@@ -651,8 +654,11 @@ construct_boot_order(char *bootorder, int keep,
5fb29d
 
5fb29d
 	size_t new_data_size = data_size + bo.data_size;
5fb29d
 	uint16_t *new_data = calloc(1, new_data_size);
5fb29d
-	if (!new_data)
5fb29d
+	if (!new_data) {
5fb29d
+		if (data)
5fb29d
+			free(data);
5fb29d
 		return -1;
5fb29d
+	}
5fb29d
 
5fb29d
 	memcpy(new_data, data, data_size);
5fb29d
 	memcpy(new_data + (data_size / sizeof (*new_data)), bo.data,
5fb29d
-- 
5fb29d
1.9.3
5fb29d