From 6c1720e328d2ed6d5e9ac0a6a84f57ac2d360d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigrid=20Solveig=20Hafl=C3=ADnud=C3=B3ttir?= Date: Wed, 17 Nov 2021 14:14:38 +0100 Subject: [PATCH] datetime: don't crash if localtime failed --- src/uxnemu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/uxnemu.c b/src/uxnemu.c index 9bd8160..b56b975 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -384,7 +384,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);