Permalink
Browse files

Merge pull request #38 from Leonidas-from-XIV/bugfix/optional-finish-…

…entry

Make calls to the finish_entry callback optional
  • Loading branch information...
2 parents e567c8c + 2054e02 commit 59cf95f5d956023755c39a77c90b25af0da456d0 @kientzle kientzle committed Feb 17, 2013
Showing with 5 additions and 3 deletions.
  1. +5 −3 libarchive/archive_write.c
@@ -503,8 +503,9 @@ _archive_write_close(struct archive *_a)
archive_clear_error(&a->archive);
- /* Finish the last entry. */
- if (a->archive.state == ARCHIVE_STATE_DATA)
+ /* Finish the last entry if a finish callback is specified */
+ if (a->archive.state == ARCHIVE_STATE_DATA
+ && a->format_finish_entry != NULL)
r = ((a->format_finish_entry)(a));
/* Finish off the archive. */
@@ -658,7 +659,8 @@ _archive_write_finish_entry(struct archive *_a)
archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
"archive_write_finish_entry");
- if (a->archive.state & ARCHIVE_STATE_DATA)
+ if (a->archive.state & ARCHIVE_STATE_DATA
+ && a->format_finish_entry != NULL)
ret = (a->format_finish_entry)(a);
a->archive.state = ARCHIVE_STATE_HEADER;
return (ret);

0 comments on commit 59cf95f

Please sign in to comment.