From d73ed8261b68d51c185df199f943658a13122171 Mon Sep 17 00:00:00 2001 From: sECuRE Date: Sun, 30 Nov 2008 11:15:08 +0000 Subject: [PATCH] Check if read < 0 git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@89 af93e077-1a23-4f1e-9cbe-9382a9d578f5 --- src/kasse.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/kasse.c b/src/kasse.c index c82faa9..eb1cf18 100644 --- a/src/kasse.c +++ b/src/kasse.c @@ -59,7 +59,7 @@ static void log_file(const char *s) { lines, we don't need more than 100 * 64 bytes. */ char *buffer = malloc(sizeof(char) * 64 * 100); char filename[8]; - char read = 0; + int read = 0; unsigned int c; if (buffer == NULL) { cprintf("No memory available\n"); @@ -82,7 +82,10 @@ static void log_file(const char *s) { c128_perror(c, "cbm_open(log)"); sane_exit(); } - /* TODO: read < 0? */ + if (read < 0) { + cprintf("Could not read existing logfile (read returned %d)\n", read); + sane_exit(); + } strcpy(buffer+read, s); c = cbm_write((BYTE)8, buffer, read+strlen(s)); if (c != (read+strlen(s))) { -- 2.39.5