From e0b5d2be5c1eee242b347c257c950fcaa952c0b3 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 10 Sep 2014 15:46:04 -0400
Subject: [PATCH 07/31] Make sure data created for load options is freed.
Covscan... may not be right about this one. But it's better to be sure.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/lib/efi.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/lib/efi.c b/src/lib/efi.c
index 4218eb5..7dc3c92 100644
--- a/src/lib/efi.c
+++ b/src/lib/efi.c
@@ -939,6 +939,7 @@ append_extra_args(uint8_t **data, size_t *data_size)
free(new_data);
if (ret < 0)
return -1;
+ new_data = NULL;
new_data_size = 0;
}
@@ -946,15 +947,21 @@ append_extra_args(uint8_t **data, size_t *data_size)
ret = append_extra_args_unicode(&new_data, &new_data_size);
else
ret = append_extra_args_ascii(&new_data, &new_data_size);
- if (ret < 0)
+ if (ret < 0) {
+ if (new_data) /* this can't happen, but covscan believes */
+ free(new_data);
return -1;
+ }
if (new_data_size) {
ret = add_new_data(data, data_size, new_data, new_data_size);
free(new_data);
+ new_data = NULL;
if (ret < 0)
return -1;
new_data_size = 0;
}
+ if (new_data) /* once again, this can't happen, but covscan believes */
+ free(new_data);
return 0;
}
--
2.7.4