Skip to content

Commit

Permalink
Add missing null terminator after realloc (buffer resize)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Deltheil committed Jan 9, 2013
1 parent 1f40bca commit a46a370
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ buffer_resize(buffer_t *self, size_t n) {
n = nearest_multiple_of(1024, n);
self->len = n;
self->alloc = self->data = realloc(self->alloc, n + 1);
return self->alloc ? 0 : -1;
if (!self->alloc) return -1;
self->alloc[n] = '\0';
return 0;
}

/*
Expand Down

0 comments on commit a46a370

Please sign in to comment.