From 201a6c01ee0965c0562fe65e496f33eefac12c0a Mon Sep 17 00:00:00 2001 From: Sander Vanheule Date: Fri, 3 Feb 2023 23:03:15 +0100 Subject: [PATCH] tplink-safeloader: stricter free_image_partition() Instead of only free()-ing the allocated data block, also clear the name and size of a payload entry to indicate that it's become invalid. Signed-off-by: Sander Vanheule --- src/tplink-safeloader.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/tplink-safeloader.c b/src/tplink-safeloader.c index d9e1605..6c4689c 100644 --- a/src/tplink-safeloader.c +++ b/src/tplink-safeloader.c @@ -3156,8 +3156,15 @@ static void set_partition_names(struct device_info *info) } /** Frees an image partition */ -static void free_image_partition(struct image_partition_entry entry) { - free(entry.data); +static void free_image_partition(struct image_partition_entry *entry) +{ + void *data = entry->data; + + entry->name = NULL; + entry->size = 0; + entry->data = NULL; + + free(data); } static time_t source_date_epoch = -1; @@ -3598,7 +3605,7 @@ static void build_image(const char *output, free(image); for (i = 0; parts[i].name; i++) - free_image_partition(parts[i]); + free_image_partition(&parts[i]); } /** Usage output */ -- 2.30.2