From fb8658b1d19ac73004fac8a74544416d41468d7f Mon Sep 17 00:00:00 2001 From: Brett Gordon Date: Sun, 7 May 2017 21:32:12 -0400 Subject: [PATCH] dasm09: actually handle errors. --- Applications/dasm09/dasm09.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Applications/dasm09/dasm09.c b/Applications/dasm09/dasm09.c index 7cb36e6f..022a39ca 100755 --- a/Applications/dasm09/dasm09.c +++ b/Applications/dasm09/dasm09.c @@ -40,15 +40,24 @@ uint16_t offset = 0; #define ARGBYTE(address) getb(address) #define ARGWORD(address) getword(address) + +static void readerr(void) +{ + perror("infile"); + exit(1); +} + static uint8_t getb(uint16_t addr) { - fseek(infile, addr-offset, SEEK_SET); + if (fseek(infile, addr-offset, SEEK_SET)<0) + readerr(); return getc(infile); } static uint16_t getword(uint16_t addr) { - fseek(infile, addr-offset, SEEK_SET); + if (fseek(infile, addr-offset, SEEK_SET)<0) + readerr(); return (getc(infile)<<8) | getc(infile); } -- 2.34.1