From c513448e9181e457170d2a1fc367a6e891844e1b Mon Sep 17 00:00:00 2001 From: Paul Barker Date: Sat, 26 Sep 2015 19:38:13 +0100 Subject: [PATCH] Issue 578: Close temp_fd in 7zip and xar writers The ISO9660 writer uses a temp_fd and closes it in the archive_free handler. The same logic is added to the archive_free handlers for the 7zip and xar writers. Signed-off-by: Paul Barker --- libarchive/archive_write_set_format_7zip.c | 4 ++++ libarchive/archive_write_set_format_xar.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/libarchive/archive_write_set_format_7zip.c b/libarchive/archive_write_set_format_7zip.c index 7847cb3c5..fc6ccfe0b 100644 --- a/libarchive/archive_write_set_format_7zip.c +++ b/libarchive/archive_write_set_format_7zip.c @@ -1450,6 +1450,10 @@ _7z_free(struct archive_write *a) { struct _7zip *zip = (struct _7zip *)a->format_data; + /* Close the temporary file. */ + if (zip->temp_fd >= 0) + close(zip->temp_fd); + file_free_register(zip); compression_end(&(a->archive), &(zip->stream)); free(zip->coder.props); diff --git a/libarchive/archive_write_set_format_xar.c b/libarchive/archive_write_set_format_xar.c index 4538befd9..a2dbc0399 100644 --- a/libarchive/archive_write_set_format_xar.c +++ b/libarchive/archive_write_set_format_xar.c @@ -1877,6 +1877,11 @@ xar_free(struct archive_write *a) struct xar *xar; xar = (struct xar *)a->format_data; + + /* Close the temporary file. */ + if (xar->temp_fd >= 0) + close(xar->temp_fd); + archive_string_free(&(xar->cur_dirstr)); archive_string_free(&(xar->tstr)); archive_string_free(&(xar->vstr)); -- 2.47.2