From 756d8a49d962bbceb67ab07f953c63982204b772 Mon Sep 17 00:00:00 2001 From: "(Tim) Efthimis Kritikos" Date: Tue, 23 Jan 2024 17:43:08 +0000 Subject: [PATCH] main: fixed error handling when we can't read rom file --- main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.c b/main.c index 68cc409..f088a07 100644 --- a/main.c +++ b/main.c @@ -23,6 +23,7 @@ #include "simdata.h" #include "stdint.h" #include +#include void help(char* progname){ printf("Usage: %s -i \n", progname); @@ -54,6 +55,13 @@ int main(int argc, char* argd[] ){ /// READ ROM FILE /// FILE* rom=fopen(infile,"r"); + + if (rom == NULL) { + printf("ERROR: Couldn't open rom file\n"); + perror(infile); + return 1; + } + fseek(rom, 0, SEEK_END); if(ftell(rom)!=16777216){ printf("ERROR: ROM file isn't 16MiB\n");