summaryrefslogtreecommitdiff
path: root/malloc
diff options
context:
space:
mode:
authorAndreas Schwab <aschwab@redhat.com>2009-06-26 13:14:24 +0200
committerAndreas Schwab <aschwab@redhat.com>2009-06-26 13:14:24 +0200
commita879c2cb1753c3aa868aa1e9d2107e9f0deb0dc2 (patch)
treea919978ad8a178a0e6013f1ee43ab54f60a13493 /malloc
parent5f9df8e7b478cafd4528a133201f4611a963292e (diff)
parent44d20bca52ace85850012b0ead37b360e3ecd96e (diff)
Merge commit 'origin/master' into fedora/master
Diffstat (limited to 'malloc')
-rw-r--r--malloc/malloc.c29
-rwxr-xr-xmalloc/memusage.sh2
2 files changed, 28 insertions, 3 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 0b9facefd4..516d401991 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -4241,6 +4241,8 @@ _int_malloc(mstate av, size_t bytes)
mchunkptr fwd; /* misc temp for linking */
mchunkptr bck; /* misc temp for linking */
+ const char *errstr = NULL;
+
/*
Convert request size to internal form by adding SIZE_SZ bytes
overhead plus possibly more to obtain necessary alignment and/or
@@ -4276,8 +4278,11 @@ _int_malloc(mstate av, size_t bytes)
#endif
if (victim != 0) {
if (__builtin_expect (fastbin_index (chunksize (victim)) != idx, 0))
- malloc_printerr (check_action, "malloc(): memory corruption (fast)",
- chunk2mem (victim));
+ {
+ errstr = "malloc(): memory corruption (fast)";
+ errout:
+ malloc_printerr (check_action, errstr, chunk2mem (victim));
+ }
#ifndef ATOMIC_FASTBINS
*fb = victim->fd;
#endif
@@ -4306,6 +4311,11 @@ _int_malloc(mstate av, size_t bytes)
malloc_consolidate(av);
else {
bck = victim->bk;
+ if (__builtin_expect (bck->fd != victim, 0))
+ {
+ errstr = "malloc(): smallbin double linked list corrupted";
+ goto errout;
+ }
set_inuse_bit_at_offset(victim, nb);
bin->bk = bck;
bck->fd = bin;
@@ -4515,6 +4525,11 @@ _int_malloc(mstate av, size_t bytes)
have to perform a complete insert here. */
bck = unsorted_chunks(av);
fwd = bck->fd;
+ if (__builtin_expect (fwd->bk != bck, 0))
+ {
+ errstr = "malloc(): corrupted unsorted chunks";
+ goto errout;
+ }
remainder->bk = bck;
remainder->fd = fwd;
bck->fd = remainder;
@@ -4610,6 +4625,11 @@ _int_malloc(mstate av, size_t bytes)
have to perform a complete insert here. */
bck = unsorted_chunks(av);
fwd = bck->fd;
+ if (__builtin_expect (fwd->bk != bck, 0))
+ {
+ errstr = "malloc(): corrupted unsorted chunks 2";
+ goto errout;
+ }
remainder->bk = bck;
remainder->fd = fwd;
bck->fd = remainder;
@@ -4901,6 +4921,11 @@ _int_free(mstate av, mchunkptr p)
bck = unsorted_chunks(av);
fwd = bck->fd;
+ if (__builtin_expect (fwd->bk != bck, 0))
+ {
+ errstr = "free(): corrupted unsorted chunks";
+ goto errout;
+ }
p->fd = fwd;
p->bk = bck;
if (!in_smallbin_range(size))
diff --git a/malloc/memusage.sh b/malloc/memusage.sh
index 8b372e4b8e..9fab0a3b8b 100755
--- a/malloc/memusage.sh
+++ b/malloc/memusage.sh
@@ -62,7 +62,7 @@ Mandatory arguments to long options are also mandatory for any corresponding
short options.
"
- print $"For bug reporting instructions, please see:
+ echo $"For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
"
exit 0