From e7626f7aa1e5947f8235728fed5af862b27a719e Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 10 Sep 2014 16:15:27 -0400 Subject: [PATCH 12/31] 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 --- 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); -- 2.7.4