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 <san...@svanheule.net> --- 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 d9e16058883c..6c4689c2f67c 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.39.0 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel