[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-btrace
Subject:    [PATCH] blktrace:  pass a valid pointer to realloc.
From:       Matthew Boyle <mlb () corefiling ! co ! uk>
Date:       2011-06-20 13:12:17
Message-ID: 4DFF4731.6010001 () corefiling ! co ! uk
[Download RAW message or body]

When blktrace is writing to stdout, and there's sufficient disk activity
to fill the trace buffer, tb_combine() tries to increase the buffer
size.  But the pointer it passes to realloc isn't to the head of the
block of memory.  glibc's realloc gets really quite upset at this, and
aborts the process.

This just passes in the pointer handed out by malloc.

Signed-off-by: Matt Boyle <mlb@corefiling.co.uk>
---
  blktrace.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)



["0001-blktrace-pass-a-valid-pointer-to-realloc.patch" (text/x-patch)]

diff --git a/blktrace.c b/blktrace.c
index 72866e2..d4d5111 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -1330,7 +1330,7 @@ static struct trace_buf *tb_combine(struct trace_buf *prev,
 		 * the whole structures, as the other fields
 		 * are "static".
 		 */
-		prev = realloc(prev->buf, sizeof(*prev) + tot_len);
+		prev = realloc(prev, sizeof(*prev) + tot_len);
 		prev->buf = (void *)(prev + 1);
 	}
 


--
To unsubscribe from this list: send the line "unsubscribe linux-btrace" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic