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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user