Archived
1
0
Fork 0

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.
This commit is contained in:
Henrik Hautakoski 2012-07-04 13:53:33 +02:00
parent ae91737fb1
commit d18d581fd0

View file

@ -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);
}