1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-12 10:22:38 +02:00

heap_alloc: avoid integer overflow

* gl/lib/heap.c (heap_alloc): Use xnmalloc rather than xmalloc,
to avoid pathological overflow.
This commit is contained in:
Jim Meyering
2010-07-14 11:05:50 -05:00
parent 66af887e57
commit c5e350ec56

View File

@@ -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;