From 0b8c0818a042a2eea53695315c43fa5826c0baf3 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 31 Dec 2012 13:16:03 +1100 Subject: [PATCH] Check for successful calloc of hash table only after performing it. --- rzip.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rzip.c b/rzip.c index c83345a..7644ae1 100644 --- a/rzip.c +++ b/rzip.c @@ -605,11 +605,10 @@ static bool hash_search(rzip_control *control, struct rzip_state *st, double pct /* 66% full at max. */ st->hash_limit = (1 << st->hash_bits) / 3 * 2; st->hash_table = calloc(sizeof(st->hash_table[0]), (1 << st->hash_bits)); + if (unlikely(!st->hash_table)) + fatal_return(("Failed to allocate hash table in hash_search\n"), false); } - if (unlikely(!st->hash_table)) - fatal_return(("Failed to allocate hash table in hash_search\n"), false); - st->minimum_tag_mask = tag_mask; st->tag_clean_ptr = 0; st->cksum = 0;