[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Returned mail: see transcript for details
From: |
Wolfram Gloger |
Subject: |
Re: Returned mail: see transcript for details |
Date: |
Tue, 11 Jun 2002 11:42:21 +0200 (MDT) |
> If you allocate enough memory so that eventually malloc would normally return
> NULL because it can't allocate any more memory, the current version of malloc
> from cvs will cause a segmentation violation (on systems that trap access to
> NULL). This is due to the fact that new_heap returns NULL when it can't
> allocate a new heap. The January 29th rewrite of malloc introduced the bug.
Thanks, this was a copy'n'paste error with respect to braces, AFAICS.
The patch below doesn't add an extra return path and is therefore more
in line with Lea's original sources.
Regards,
Wolfram.
2002-06-11 Wolfram Gloger <address@hidden>
* malloc/malloc.c: Fix error path when new_heap() returns
NULL. Reported by Michael Meissner <address@hidden>.
--- malloc.c 2002/05/12 21:16:52 1.9
+++ malloc.c 2002/06/11 09:33:59
@@ -2786,20 +2786,17 @@
#endif
set_head(old_top, (((char *)old_heap + old_heap->size) - (char *)old_top)
| PREV_INUSE);
- } else {
- /* A new heap must be created. */
- heap = new_heap(nb + (MINSIZE + sizeof(*heap)), mp_.top_pad);
- if(heap) {
- heap->ar_ptr = av;
- heap->prev = old_heap;
- av->system_mem += heap->size;
- arena_mem += heap->size;
+ }
+ else if ((heap = new_heap(nb + (MINSIZE + sizeof(*heap)), mp_.top_pad))) {
+ /* Use a newly allocated heap. */
+ heap->ar_ptr = av;
+ heap->prev = old_heap;
+ av->system_mem += heap->size;
+ arena_mem += heap->size;
#if 0
- if((unsigned long)(mmapped_mem + arena_mem + sbrked_mem) >
max_total_mem)
- max_total_mem = mmapped_mem + arena_mem + sbrked_mem;
+ if((unsigned long)(mmapped_mem + arena_mem + sbrked_mem) > max_total_mem)
+ max_total_mem = mmapped_mem + arena_mem + sbrked_mem;
#endif
- }
-
/* Set up the new top. */
top(av) = chunk_at_offset(heap, sizeof(*heap));
set_head(top(av), (heap->size - sizeof(*heap)) | PREV_INUSE);