about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-09-09 01:58:35 +0000
committerUlrich Drepper <drepper@redhat.com>2004-09-09 01:58:35 +0000
commit9d0cdc0eeaf8b0ca19bf04c5e18b00d965fcd0a8 (patch)
treee4f8023b9d5219537e107005002bc57cc33a6576
parent4924c0072b10d1e72662f02448b96cd6129c445b (diff)
downloadglibc-9d0cdc0eeaf8b0ca19bf04c5e18b00d965fcd0a8.tar.gz
glibc-9d0cdc0eeaf8b0ca19bf04c5e18b00d965fcd0a8.tar.xz
glibc-9d0cdc0eeaf8b0ca19bf04c5e18b00d965fcd0a8.zip
Update.
2004-09-08  Ulrich Drepper  <drepper@redhat.com>

	* malloc/malloc.c (_int_free): Add inexpensive double free test.
-rw-r--r--ChangeLog4
-rw-r--r--malloc/malloc.c7
2 files changed, 11 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a906d61b11..c0623993b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2004-09-08  Ulrich Drepper  <drepper@redhat.com>
+
+	* malloc/malloc.c (_int_free): Add inexpensive double free test.
+
 2004-09-08  Roland McGrath  <roland@redhat.com>
 
 	* malloc/mcheck.c: Don't use __P.
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;
     }