Skip to contentSkip to conversation

(resend) blktrace: incorrect pointer passed to realloc.

PATCH New Matthew Boyle 1 participant 1 message Aug 16, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 (resend) blktrace: incorrect pointer passed to realloc.

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.

---
  blktrace.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
blktrace.c +1 -1
index 72866e2..d4d5111 100644
@@ -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);
 	}