]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix a cause of segmentation fault in case of creating a child
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Fri, 5 Oct 2012 05:28:02 +0000 (14:28 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Fri, 5 Oct 2012 05:28:02 +0000 (14:28 +0900)
process failed. It occured when archive_write_close() was called
after an opening filter process failed.

libarchive/archive_write.c

index 6fc3907f3631b9f0eb015ce04623befb07ce19ca..a3d1a3380c05b8ac3799211ce4bbe2d4b8b3676b 100644 (file)
@@ -232,6 +232,10 @@ __archive_write_filter(struct archive_write_filter *f,
        int r;
        if (length == 0)
                return(ARCHIVE_OK);
+       if (f->write == NULL)
+               /* If unset, a fatal error has already ocuured, so this filter
+                * didn't open. We cannot write anything. */
+               return(ARCHIVE_FATAL);
        r = (f->write)(f, buff, length);
        f->bytes_written += length;
        return (r);
@@ -437,6 +441,8 @@ archive_write_client_close(struct archive_write_filter *f)
                (*a->client_closer)(&a->archive, a->client_data);
        free(state->buffer);
        free(state);
+       /* Clear the close handler myself not to be called again. */
+       f->close = NULL;
        a->client_data = NULL;
        return (ret);
 }