coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[coreutils] [PATCH] heap_alloc: avoid integer overflow


From: Jim Meyering
Subject: [coreutils] [PATCH] heap_alloc: avoid integer overflow
Date: Wed, 14 Jul 2010 18:26:53 +0200

FYI,

>From c5e350ec5625d7346c2a088fe478060358200c14 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
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 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gl/lib/heap.c b/gl/lib/heap.c
index 1de3391..4672b6d 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;
--
1.7.1.460.gf3c4c



reply via email to

[Prev in Thread] Current Thread [Next in Thread]