summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2014-06-24 19:06:05 +0200
committerTobias Klauser <tklauser@distanz.ch>2014-06-25 10:18:09 +0200
commit46b0ace509d9ed013915e9ab8013c7c712e11395 (patch)
treea2882741a458995c1d3303bf87e6c88ea17724a2 /hash.c
parent6424dd90f721fd968c1159236f525ed59f355045 (diff)
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 <tklauser@distanz.ch>
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c2
1 files changed, 1 insertions, 1 deletions
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;