summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2010-07-19 02:00:03 +0200
committerJohannes Weiner <hannes@cmpxchg.org>2010-07-19 02:00:03 +0200
commit170a09436416549f3c9050eae5f20f39c8df8a20 (patch)
tree4e1dfb56bac7c393fef929d88d577e96e88beb61
parentcefec02ae2f32b3d94c92b2bfe1f05de76bab150 (diff)
lib/io: properly initialize line buffer
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
-rw-r--r--lib/io.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/io.c b/lib/io.c
index 53cc27a..957adcc 100644
--- a/lib/io.c
+++ b/lib/io.c
@@ -137,7 +137,7 @@ static sheep_t write(struct sheep_vm *vm, unsigned int nr_args)
/* (readline file) */
static sheep_t readline(struct sheep_vm *vm, unsigned int nr_args)
{
- char *str = NULL, *endp = NULL, buf[512];
+ char *str, *endp = NULL, buf[512];
unsigned long len = 0;
struct file *file;
@@ -147,6 +147,7 @@ static sheep_t readline(struct sheep_vm *vm, unsigned int nr_args)
if (!file_check(vm, file))
return NULL;
+ str = sheep_zalloc(1);
while (!endp && fgets(buf, sizeof(buf), file->filp)) {
unsigned long delta;