]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Free any allocated memory upon allocation failure 559/head
authorColin Percival <cperciva@tarsnap.com>
Sat, 30 May 2015 06:20:57 +0000 (23:20 -0700)
committerColin Percival <cperciva@tarsnap.com>
Tue, 2 Jun 2015 05:21:08 +0000 (22:21 -0700)
libarchive/archive_write_disk_set_standard_lookup.c

index cf544dd7b608500ecedb832798b710b2efae742f..3b868fbad195e2b4e7f0090b238b5db6baa447b4 100644 (file)
@@ -86,6 +86,11 @@ archive_write_disk_set_standard_lookup(struct archive *a)
 {
        struct bucket *ucache = malloc(cache_size * sizeof(struct bucket));
        struct bucket *gcache = malloc(cache_size * sizeof(struct bucket));
+       if (ucache == NULL || gcache == NULL) {
+               free(ucache);
+               free(gcache);
+               return (ARCHIVE_FATAL);
+       }
        memset(ucache, 0, cache_size * sizeof(struct bucket));
        memset(gcache, 0, cache_size * sizeof(struct bucket));
        archive_write_disk_set_group_lookup(a, gcache, lookup_gid, cleanup);