Blob Blame History Raw
From 939f9700414785f51579ba25a2c76a90d161ec31 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 10 Sep 2014 16:15:27 -0400
Subject: [PATCH 11/18] Don't free something that shouldn't ever be non-NULL.

Instead, check and error if it's non-NULL.

(Covscan, which got this completely wrong.)

Signed-off-by: Peter Jones <pjones@redhat.com>
---
 src/lib/efi.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/lib/efi.c b/src/lib/efi.c
index a131abe..f604a1a 100644
--- a/src/lib/efi.c
+++ b/src/lib/efi.c
@@ -792,7 +792,7 @@ append_extra_args_ascii(uint8_t **data, size_t *data_size)
 	int i;
 	unsigned long usedchars=0;
 
-	if (!data)
+	if (!data || *data)
 		return -1;
 
 	for (i=opts.optind; i < opts.argc; i++)	{
@@ -816,8 +816,6 @@ append_extra_args_ascii(uint8_t **data, size_t *data_size)
 	if (!new_data)
 		return 0;
 
-	if (*data)
-		free(*data);
 	*data = (uint8_t *)new_data;
 	*data_size = usedchars;
 
@@ -831,7 +829,7 @@ append_extra_args_unicode(uint8_t **data, size_t *data_size)
 	int i;
 	unsigned long usedchars=0;
 
-	if (!data)
+	if (!data || *data)
 		return -1;
 
 	for (i = opts.optind; i < opts.argc; i++) {
@@ -857,8 +855,6 @@ append_extra_args_unicode(uint8_t **data, size_t *data_size)
 	if (!new_data)
 		return 0;
 
-	if (*data)
-		free(*data);
 	*data = (uint8_t *)new_data;
 	*data_size = usedchars * sizeof (*new_data);
 
-- 
1.9.3