--- malloc.c.orig 2014-09-02 17:53:21.233522659 -0700 +++ malloc.c 2014-09-02 18:04:28.608777748 -0700 @@ -1421,35 +1421,40 @@ #define last(b) ((b)->bk) /* Take a chunk off a bin list */ -#define unlink(AV, P, BK, FD) { \ - FD = P->fd; \ - BK = P->bk; \ - if (__builtin_expect (FD->bk != P || BK->fd != P, 0)) { \ - mutex_unlock(&(AV)->mutex); \ - malloc_printerr (check_action, "corrupted double-linked list", P); \ - mutex_lock(&(AV)->mutex); \ - } else { \ - FD->bk = BK; \ - BK->fd = FD; \ - if (!in_smallbin_range (P->size) \ - && __builtin_expect (P->fd_nextsize != NULL, 0)) { \ - assert (P->fd_nextsize->bk_nextsize == P); \ - assert (P->bk_nextsize->fd_nextsize == P); \ - if (FD->fd_nextsize == NULL) { \ - if (P->fd_nextsize == P) \ - FD->fd_nextsize = FD->bk_nextsize = FD; \ - else { \ - FD->fd_nextsize = P->fd_nextsize; \ - FD->bk_nextsize = P->bk_nextsize; \ - P->fd_nextsize->bk_nextsize = FD; \ - P->bk_nextsize->fd_nextsize = FD; \ - } \ - } else { \ - P->fd_nextsize->bk_nextsize = P->bk_nextsize; \ - P->bk_nextsize->fd_nextsize = P->fd_nextsize; \ - } \ - } \ - } \ +#define unlink(AV, P, BK, FD) { \ + FD = P->fd; \ + BK = P->bk; \ + if (__builtin_expect (FD->bk != P || BK->fd != P, 0)) { \ + mutex_unlock(&(AV)->mutex); \ + malloc_printerr (check_action, "corrupted linked list (main)", P); \ + mutex_lock(&(AV)->mutex); \ + } else { \ + FD->bk = BK; \ + BK->fd = FD; \ + if (!in_smallbin_range (P->size) \ + && __builtin_expect (P->fd_nextsize != NULL, 0)) { \ + if (__builtin_expect (P->fd_nextsize->bk_nextsize != P \ + || P->bk_nextsize->fd_nextsize != P, 0)) { \ + mutex_unlock(&(AV)->mutex); \ + malloc_printerr (check_action, "corrupted linked list (large)", P); \ + mutex_lock(&(AV)->mutex); \ + } else { \ + if (FD->fd_nextsize == NULL) { \ + if (P->fd_nextsize == P) \ + FD->fd_nextsize = FD->bk_nextsize = FD; \ + else { \ + FD->fd_nextsize = P->fd_nextsize; \ + FD->bk_nextsize = P->bk_nextsize; \ + P->fd_nextsize->bk_nextsize = FD; \ + P->bk_nextsize->fd_nextsize = FD; \ + } \ + } else { \ + P->fd_nextsize->bk_nextsize = P->bk_nextsize; \ + P->bk_nextsize->fd_nextsize = P->fd_nextsize; \ + } \ + } \ + } \ + } \ } /*