about summary refs log tree commit diff
path: root/malloc/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'malloc/malloc.c')
-rw-r--r--malloc/malloc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 5636d5cfb0..4db40514d6 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -4201,6 +4201,13 @@ _int_free(mstate av, Void_t* mem)
 
       set_fastchunks(av);
       fb = &(av->fastbins[fastbin_index(size)]);
+      /* Another simple check: make sure the top of the bin is not the
+	 record we are going to add (i.e., double free).  */
+      if (__builtin_expect (*fb == p, 0))
+	{
+	  malloc_printf_nc (check_action, "double free(%p)!\n", mem);
+	  return;
+	}
       p->fd = *fb;
       *fb = p;
     }