aboutsummaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-03-31 10:42:21 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-03-31 10:42:21 +0200
commit5bb67f6738f0eb99558618412cd0b035538f77c5 (patch)
tree0c34a4b307055a947f0bff0c1a100b448155d308 /buffer.c
parentd95f7600f30f80a80af590e7b1386b065d6fe8e7 (diff)
downloadvis-5bb67f6738f0eb99558618412cd0b035538f77c5.tar.gz
vis-5bb67f6738f0eb99558618412cd0b035538f77c5.tar.xz
Check return value of realloc
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/buffer.c b/buffer.c
index a3e623d..6763676 100644
--- a/buffer.c
+++ b/buffer.c
@@ -12,13 +12,11 @@ bool buffer_alloc(Buffer *buf, size_t size) {
if (buf->size < size) {
if (buf->size > 0)
size *= 2;
- buf->data = realloc(buf->data, size);
- if (!buf->data) {
- buf->size = 0;
- buf->len = 0;
+ char *data = realloc(buf->data, size);
+ if (!data)
return false;
- }
buf->size = size;
+ buf->data = data;
}
return true;
}