From: Mike Frysinger Date: Tue, 23 Apr 2019 14:32:11 +0000 (+1000) Subject: fix memory leak with repeated header reads X-Git-Tag: v3.4.0~63^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F1177%2Fhead;p=thirdparty%2Flibarchive.git fix memory leak with repeated header reads Make sure the name field is reset/cleared when re-reading the header. Closes #1176. --- 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. */