PERFORCE change 145885 for review
Tim Kientzle
kientzle at freebsd.org
Fri Jul 25 14:52:53 UTC 2008
Anselm Strauss wrote:
> http://perforce.freebsd.org/chv.cgi?CH=145885
>
> Change 145885 by strauss at strauss_marvelman on 2008/07/25 13:32:02
>
> Cloning archive entry instead of referencing it for data descriptors (Tim)
>
> Affected files ...
>
> .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#18 edit
> .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_format_zip_no_compression.c#3 edit
>
> Differences ...
>
> ==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#18 (text+ko) ====
>
> @@ -173,7 +173,7 @@
> archive_set_error(&a->archive, ENOMEM, "Can't allocate zip header data");
> return (ARCHIVE_FATAL);
> }
> - l->entry = entry; /* TODO: Maybe bad idea, do copy or store only needed fields. */
> + l->entry = archive_entry_clone(entry);
> l->next = zip->central_directory;
> zip->central_directory = l;
Of course, this also means that the Zip writer now owns
a copy of the entry and it has to free it with
archive_entry_free() when it's done with it.
You should change your zip write test to use
archive_entry_free() to release the entry before
you call archive_write_close().
I'm going to run libarchive_test under a memory
debugger to see if your zip work is leaking any
memory. I'll let you know what I see.
More information about the p4-projects
mailing list