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