From c5e350ec5625d7346c2a088fe478060358200c14 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 14 Jul 2010 11:05:50 -0500 Subject: [PATCH] heap_alloc: avoid integer overflow * gl/lib/heap.c (heap_alloc): Use xnmalloc rather than xmalloc, to avoid pathological overflow. --- gl/lib/heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gl/lib/heap.c b/gl/lib/heap.c index 1de3391a5..4672b6d5b 100644 --- a/gl/lib/heap.c +++ b/gl/lib/heap.c @@ -41,7 +41,7 @@ heap_alloc (int (*compare)(const void *, const void *), size_t n_reserve) if (n_reserve == 0) n_reserve = 1; - heap->array = xmalloc (n_reserve * sizeof *(heap->array)); + heap->array = xnmalloc (n_reserve, sizeof *(heap->array)); heap->array[0] = NULL; heap->capacity = n_reserve;