]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
fix memory leak with repeated header reads 1177/head
authorMike Frysinger <vapier@gentoo.org>
Tue, 23 Apr 2019 14:32:11 +0000 (00:32 +1000)
committerMike Frysinger <vapier@gentoo.org>
Tue, 23 Apr 2019 14:32:11 +0000 (00:32 +1000)
Make sure the name field is reset/cleared when re-reading the header.

Closes #1176.

libarchive/archive_read_support_filter_gzip.c

index 0b306df0b08352f2e351bff8993561ffc2d6f868..cd24d2b1252d1312ce7f26d4d13047f22d5a8f1e 100644 (file)
@@ -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. */