This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix malloc_consolidate


Hi!

The last malloc_consolidate change causes crashes.  The do while loop
has fb++ != maxfb condition, so fb in the last iteration is equal to maxfb.
Thus, maxfb can't be pointer to the end of the array, but must point to the
last element in it.

2006-10-17  Jakub Jelinek  <jakub@redhat.com>

	[BZ #3313]
	* malloc/malloc.c (malloc_consolidate): Set maxfb to address of last
	fastbin rather than end of fastbin array.

--- libc/malloc/malloc.c.jj	2006-10-17 10:29:08.000000000 +0200
+++ libc/malloc/malloc.c	2006-10-17 14:09:56.000000000 +0200
@@ -4699,7 +4699,7 @@ static void malloc_consolidate(av) mstat
        search all bins all the time.  */
     maxfb = &(av->fastbins[fastbin_index(get_max_fast ())]);
 #else
-    maxfb = &(av->fastbins[NFASTBINS]);
+    maxfb = &(av->fastbins[NFASTBINS - 1]);
 #endif
     fb = &(av->fastbins[0]);
     do {

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]