commit e85307c7a13fc3348f0c0f3ab690186c60eaeaea
parent aecd4f2d77bd005e27495d1c949f7016a066d342
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 29 Jul 2026 11:05:39 +0200
use proper call for later versions of libarchive to avoid leak
Diffstat:
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/plugins/archive_extractor.c b/src/plugins/archive_extractor.c
@@ -109,7 +109,18 @@ EXTRACTOR_archive_extract_method (struct EXTRACTOR_ExtractContext *ec)
#endif
archive_read_support_format_all (a);
if (archive_read_open2 (a, ec, NULL, &read_cb, &skip_cb, NULL)!= ARCHIVE_OK)
+ {
+ /* Every archive_read_support_*() call above allocated reader state
+ that belongs to `a'; returning without freeing it leaks all of it.
+ This is the path every file libarchive does not recognise takes,
+ and a caller that walks a directory tree takes it once per file. */
+#if ARCHIVE_VERSION_NUMBER >= 3000000
+ archive_read_free (a);
+#else
+ archive_read_finish (a);
+#endif
return;
+ }
while (ARCHIVE_OK == archive_read_next_header (a, &entry))
{