]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
heap_alloc: avoid integer overflow
authorJim Meyering <meyering@redhat.com>
Wed, 14 Jul 2010 16:05:50 +0000 (11:05 -0500)
committerJim Meyering <meyering@redhat.com>
Wed, 14 Jul 2010 16:05:50 +0000 (11:05 -0500)
* gl/lib/heap.c (heap_alloc): Use xnmalloc rather than xmalloc,
to avoid pathological overflow.

gl/lib/heap.c

index 1de3391a598dd8af0b8a703e30e11524206267ae..4672b6d5b9d4f227006c5a9626418e620b6ad6c3 100644 (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;