]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Avoid NULL dereference when destroy functions are called more
authorJoerg Sonnenberger <joerg.sonnenberger@gmail.com>
Sat, 26 Jul 2008 00:42:01 +0000 (20:42 -0400)
committerJoerg Sonnenberger <joerg.sonnenberger@gmail.com>
Sat, 26 Jul 2008 00:42:01 +0000 (20:42 -0400)
than once.

SVN-Revision: 162

libarchive/archive_write_set_format_ar.c
libarchive/archive_write_set_format_pax.c
libarchive/archive_write_set_format_shar.c

index 7176e6e2f40531fe6d1de502a9a035466a101543..d93f3cb8dbf026f5dc1b2c308532d6e01073a5ea 100644 (file)
@@ -389,6 +389,9 @@ archive_write_ar_destroy(struct archive_write *a)
 
        ar = (struct ar_w *)a->format_data;
 
+       if (ar == NULL)
+               return (ARCHIVE_OK);
+
        if (ar->has_strtab > 0) {
                free(ar->strtab);
                ar->strtab = NULL;
index 3e294cdf0a805910647f84deebfa34863f1cb5cf..1b29c5fc7ffcd89702665d1d94d73d1bc2175731 100644 (file)
@@ -1200,6 +1200,9 @@ archive_write_pax_destroy(struct archive_write *a)
        struct pax *pax;
 
        pax = (struct pax *)a->format_data;
+       if (pax == NULL)
+               return (ARCHIVE_OK);
+
        archive_string_free(&pax->pax_header);
        free(pax);
        a->format_data = NULL;
index b5d16e09d132026ce36d96ba04fca2c7be4a8f89..a6eaebff58404cc18912d71a46c3bad2a84b4bde 100644 (file)
@@ -549,6 +549,8 @@ archive_write_shar_destroy(struct archive_write *a)
        struct shar *shar;
 
        shar = (struct shar *)a->format_data;
+       if (shar == NULL)
+               return (ARCHIVE_OK);
        if (shar->entry != NULL)
                archive_entry_free(shar->entry);
        if (shar->last_dir != NULL)