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