From d18d581fd0b73f05c6ad6cb8724baa33bd342400 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 4 Jul 2012 13:53:33 +0200 Subject: [PATCH] buffer.c: fix dereference of invalid pointer. using the pointer 'b->block' when it is possible that reallocation has moved the memory to another location. 'b->block' may therefore be an invalid pointer in some cases. use 'ret' intead. --- buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buffer.c b/buffer.c index f7bf469..0b81feb 100644 --- a/buffer.c +++ b/buffer.c @@ -67,7 +67,7 @@ char* buffer_cstr_release(struct buffer *b) { } else { ret = (char *) b->block; } - b->block[b->len + 1] = '\0'; + ret[b->len + 1] = '\0'; } else { ret = calloc(1, 1); }