]> git.ipfire.org Git - thirdparty/libarchive.git/commit
RAR5 reader: Removed a memory leak in process_head_file 1125/head
authorGrzegorz Antoniak <ga@anadoxin.org>
Fri, 18 Jan 2019 06:24:17 +0000 (07:24 +0100)
committerGrzegorz Antoniak <ga@anadoxin.org>
Fri, 18 Jan 2019 06:30:53 +0000 (07:30 +0100)
commit72f40fab252122a1daa5e3f5484ad2a802dddb70
treeefd50c89e76ba145a4ccd92cb4a98cafc7a7726d
parent520f98b00802054d3945f39000a09f60a226084a
RAR5 reader: Removed a memory leak in process_head_file

The process_head_file function was using memset() to clear the
archive_entry structure. The problem was that this structure could
contain pointers to allocated blocks of memory, and removing those
pointers with memset() resulted in a memory leak.

Switching it in favor of archive_entry_clear() effectively clears the
structure, but also releases any allocated memory blocks. This removes
the memory leak.

The commit also changes the way a temporary archive_entry instance is
being created when skipping a base block after block merge; instead of
directly creating a new instance on the stack, a constructor function
archive_entry_new() is used to ensure the new archive_entry instance is
not in an inconsistent state. This is needed because the fix described
in the first half of this commit message depends on the archive_entry
instance being in a consistent state due to the call of the
archive_entry_clear() function.
libarchive/archive_read_support_format_rar5.c