From: Colin Percival Date: Sat, 30 May 2015 06:20:57 +0000 (-0700) Subject: Free any allocated memory upon allocation failure X-Git-Tag: v3.1.900a~93^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eae949540ccd2e67cc3c058e2478fd26051422ab;p=thirdparty%2Flibarchive.git Free any allocated memory upon allocation failure --- diff --git a/libarchive/archive_write_disk_set_standard_lookup.c b/libarchive/archive_write_disk_set_standard_lookup.c index cf544dd7b..3b868fbad 100644 --- a/libarchive/archive_write_disk_set_standard_lookup.c +++ b/libarchive/archive_write_disk_set_standard_lookup.c @@ -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);