From 46b0ace509d9ed013915e9ab8013c7c712e11395 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 24 Jun 2014 19:06:05 +0200 Subject: xmalloc: Add and use xcalloc Add a wrapper for calloc which checks for integer overflows in the calculation of the size to allocate. Use xcalloc to allocate an array of objects instead of calculating the size ourselves, which might cause an integer overflow. Signed-off-by: Tobias Klauser --- hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hash.c') diff --git a/hash.c b/hash.c index 51eb627..88d59bf 100644 --- a/hash.c +++ b/hash.c @@ -94,7 +94,7 @@ static void grow_hash_table(struct hash_table *table) struct hash_table_entry *old_array = table->array, *new_array; new_size = alloc_nr(old_size); - new_array = xzmalloc(sizeof(struct hash_table_entry) * new_size); + new_array = xcalloc(new_size, sizeof(struct hash_table_entry)); table->size = new_size; table->array = new_array; -- cgit v1.2.3-54-g00ecf change='this.form.submit();'> net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
ModeNameSize