This is the mail archive of the libc-hacker@sources.redhat.com 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 double free check


Hi!

This patch fixes glibc build on ia64.

2004-09-10  Jakub Jelinek  <jakub@redhat.com>

	* malloc/malloc.c (_int_free): Only do arena boundary check for
	contiguous arenas.

--- libc/malloc/malloc.c	10 Sep 2004 10:30:43 -0000
+++ libc/malloc/malloc.c	10 Sep 2004 11:13:24 -0000
@@ -4229,8 +4229,9 @@ _int_free(mstate av, Void_t* mem)
       if (__builtin_expect (p == av->top, 0))
 	goto double_free;
       /* Or whether the next chunk is beyond the boundaries of the arena.  */
-      if (__builtin_expect ((char *) nextchunk >= ((char *) av->top
-						   + chunksize(av->top)), 0))
+      if (__builtin_expect (contiguous (av)
+			    && (char *) nextchunk
+			       >= ((char *) av->top + chunksize(av->top)), 0))
 	goto double_free;
       /* Or whether the block is actually not marked used.  */
       if (__builtin_expect (!prev_inuse(nextchunk), 0))

	Jakub


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