From: Sander Vanheule Date: Fri, 3 Feb 2023 22:03:15 +0000 (+0100) Subject: tplink-safeloader: stricter free_image_partition() X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=201a6c01ee0965c0562fe65e496f33eefac12c0a;p=project%2Ffirmware-utils.git 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 --- 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 */