commit f75f644affbf2427156bde14fe9c16298b1a9f4c
parent 19c16081c6bd374cf50e28b43332115707ce917d
Author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
Date: Wed, 17 Nov 2021 14:29:36 +0100
same fixes for uxncli
Diffstat:
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/uxncli.c b/src/uxncli.c
@@ -93,7 +93,10 @@ static Uint8
datetime_dei(Device *d, Uint8 port)
{
time_t seconds = time(NULL);
+ struct tm zt = {0};
struct tm *t = localtime(&seconds);
+ if(t == NULL)
+ t = &zt;
switch(port) {
case 0x0: return (t->tm_year + 1900) >> 8;
case 0x1: return (t->tm_year + 1900);
@@ -155,9 +158,11 @@ static int
load(Uxn *u, char *filepath)
{
FILE *f;
- if(!(f = fopen(filepath, "rb")))
- return 0;
- fread(u->ram.dat + PAGE_PROGRAM, sizeof(u->ram.dat) - PAGE_PROGRAM, 1, f);
+ int r;
+ if(!(f = fopen(filepath, "rb"))) return 0;
+ r = fread(u->ram.dat + PAGE_PROGRAM, 1, sizeof(u->ram.dat) - PAGE_PROGRAM, f);
+ fclose(f);
+ if(r < 1) return 0;
fprintf(stderr, "Loaded %s\n", filepath);
return 1;
}