From: Jim Meyering Date: Wed, 14 Jul 2010 16:05:50 +0000 (-0500) Subject: heap_alloc: avoid integer overflow X-Git-Tag: v8.6~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5e350ec5625d7346c2a088fe478060358200c14;p=thirdparty%2Fcoreutils.git heap_alloc: avoid integer overflow * gl/lib/heap.c (heap_alloc): Use xnmalloc rather than xmalloc, to avoid pathological overflow. --- diff --git a/gl/lib/heap.c b/gl/lib/heap.c index 1de3391a59..4672b6d5b9 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;