00db10
commit 52ffbdf25a1100986f4ae27bb0febbe5a722ab25
00db10
Author: Florian Weimer <fweimer@redhat.com>
00db10
Date:   Wed Sep 10 20:29:15 2014 +0200
00db10
00db10
    malloc: additional unlink hardening for non-small bins [BZ #17344]
00db10
    
00db10
    Turn two asserts into a conditional call to malloc_printerr.  The
00db10
    memory locations are accessed later anyway, so the performance
00db10
    impact is minor.
00db10
00db10
Index: b/malloc/malloc.c
00db10
===================================================================
00db10
--- a/malloc/malloc.c
00db10
+++ b/malloc/malloc.c
00db10
@@ -1441,8 +1441,11 @@ typedef struct malloc_chunk* mbinptr;
00db10
     BK->fd = FD;                                                       \
00db10
     if (!in_smallbin_range (P->size)				       \
00db10
 	&& __builtin_expect (P->fd_nextsize != NULL, 0)) {	       \
00db10
-      assert (P->fd_nextsize->bk_nextsize == P);		       \
00db10
-      assert (P->bk_nextsize->fd_nextsize == P);		       \
00db10
+      if (__builtin_expect (P->fd_nextsize->bk_nextsize != P, 0)       \
00db10
+	  || __builtin_expect (P->bk_nextsize->fd_nextsize != P, 0))   \
00db10
+	malloc_printerr (check_action,				       \
00db10
+			 "corrupted double-linked list (not small)", P,\
00db10
+			 AV);					       \
00db10
       if (FD->fd_nextsize == NULL) {				       \
00db10
 	if (P->fd_nextsize == P)				       \
00db10
 	  FD->fd_nextsize = FD->bk_nextsize = FD;		       \