From: Michihiro NAKAJIMA Date: Tue, 17 May 2011 10:41:03 +0000 (-0400) Subject: Properly free struct isofile object when some fatal error happened. X-Git-Tag: v3.0.0a~332 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b43bebf45d1df6f143f688578a98c578d25f2dfd;p=thirdparty%2Flibarchive.git Properly free struct isofile object when some fatal error happened. SVN-Revision: 3355 --- diff --git a/libarchive/archive_write_set_format_iso9660.c b/libarchive/archive_write_set_format_iso9660.c index 40c7dbcff..188e78c7b 100644 --- a/libarchive/archive_write_set_format_iso9660.c +++ b/libarchive/archive_write_set_format_iso9660.c @@ -1539,8 +1539,10 @@ iso9660_write_header(struct archive_write *a, struct archive_entry *entry) return (ARCHIVE_FATAL); } r = isofile_gen_utility_names(a, file); - if (r < ARCHIVE_WARN) + if (r < ARCHIVE_WARN) { + isofile_free(file); return (r); + } else if (r < ret) ret = r; isofile_add_entry(iso9660, file); @@ -4604,7 +4606,6 @@ isofile_gen_utility_names(struct archive_write *a, struct isofile *file) */ if (0 > archive_entry_pathname_l(file->entry, &u16, &u16len, iso9660->sconv_to_utf16be)) { - isofile_free(file); if (errno == ENOMEM) { archive_set_error(&a->archive, ENOMEM, "Can't allocate memory for UTF-16BE"); @@ -5094,7 +5095,10 @@ isoent_create_virtual_dir(struct archive_write *a, struct iso9660 *iso9660, cons archive_entry_set_gid(file->entry, getgid()); archive_entry_set_mode(file->entry, 0555 | AE_IFDIR); archive_entry_set_nlink(file->entry, 2); - isofile_gen_utility_names(a, file); + if (isofile_gen_utility_names(a, file) < ARCHIVE_WARN) { + isofile_free(file); + return (NULL); + } isofile_add_entry(iso9660, file); isoent = isoent_new(file); @@ -7012,8 +7016,10 @@ isoent_create_boot_catalog(struct archive_write *a, struct isoent *rootent) archive_entry_set_mode(file->entry, AE_IFREG | 0444); archive_entry_set_nlink(file->entry, 1); - if (isofile_gen_utility_names(a, file) == ARCHIVE_FATAL) + if (isofile_gen_utility_names(a, file) < ARCHIVE_WARN) { + isofile_free(file); return (ARCHIVE_FATAL); + } file->boot = BOOT_CATALOG; file->content.size = LOGICAL_BLOCK_SIZE; isofile_add_entry(iso9660, file);