]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
[BZ #2775]
authorUlrich Drepper <drepper@redhat.com>
Thu, 7 Sep 2006 16:06:54 +0000 (16:06 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 7 Sep 2006 16:06:54 +0000 (16:06 +0000)
* malloc/malloc.c (sYSMALLOc): Only call grow_heap if
(long) (MINSIZE + nb - old_size) is positive.

* malloc/arena.c (grow_heap): When growing bail even if new_size
is negative.

ChangeLog
malloc/arena.c
malloc/malloc.c

index 67249ee23475ab1c4d67cdb7e1ead3cde938be07..aa8080e57dec034648aa7435ff176324c051f3a2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2006-09-07  Jakub Jelinek  <jakub@redhat.com>
 
+       [BZ #2775]
+       * malloc/malloc.c (sYSMALLOc): Only call grow_heap if
+       (long) (MINSIZE + nb - old_size) is positive.
+
+       * malloc/arena.c (grow_heap): When growing bail even if new_size
+       is negative.
+
        [BZ #3155]
        * sysdeps/powerpc/powerpc32/fpu/s_lrint.S (__lrint): Don't access
        stack below r1.
index 6f4b0c497b4fad01dd90c0d24282d71879325b44..2179174d6412e4d49c3236a5997f8f1ed006f484 100644 (file)
@@ -712,7 +712,7 @@ grow_heap(h, diff) heap_info *h; long diff;
   if(diff >= 0) {
     diff = (diff + page_mask) & ~page_mask;
     new_size = (long)h->size + diff;
-    if(new_size > HEAP_MAX_SIZE)
+    if((unsigned long) new_size > (unsigned long) HEAP_MAX_SIZE)
       return -1;
     if(mprotect((char *)h + h->size, diff, PROT_READ|PROT_WRITE) != 0)
       return -2;
index 206f3e1b6a9dac3a9d75ab1cc01793ba6d57c819..a369001520395a1f7fd7b7411bba6c98e04d2391 100644 (file)
@@ -2970,7 +2970,8 @@ static Void_t* sYSMALLOc(nb, av) INTERNAL_SIZE_T nb; mstate av;
     /* First try to extend the current heap. */
     old_heap = heap_for_ptr(old_top);
     old_heap_size = old_heap->size;
-    if (grow_heap(old_heap, MINSIZE + nb - old_size) == 0) {
+    if ((long) (MINSIZE + nb - old_size) > 0
+       && grow_heap(old_heap, MINSIZE + nb - old_size) == 0) {
       av->system_mem += old_heap->size - old_heap_size;
       arena_mem += old_heap->size - old_heap_size;
 #if 0