From e389bc9bf271a7978c697fa3314d6c046abca237 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 24 Apr 2019 00:32:11 +1000 Subject: [PATCH] fix memory leak with repeated header reads Make sure the name field is reset/cleared when re-reading the header. Closes #1176. --- libarchive/archive_read_support_filter_gzip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libarchive/archive_read_support_filter_gzip.c b/libarchive/archive_read_support_filter_gzip.c index 0b306df0b..cd24d2b12 100644 --- a/libarchive/archive_read_support_filter_gzip.c +++ b/libarchive/archive_read_support_filter_gzip.c @@ -178,8 +178,11 @@ peek_at_header(struct archive_read_filter *filter, int *pbits, return (0); } while (p[len - 1] != 0); - if (state) + if (state) { + /* Reset the name in case of repeat header reads. */ + free(state->name); state->name = strdup((const char *)&p[file_start]); + } } /* Null-terminated optional comment. */ -- 2.47.2