From c68645a08fc169b6d55a16db64864aecffa01926 Mon Sep 17 00:00:00 2001 From: james palmer Date: Tue, 12 Apr 2022 16:04:39 +0100 Subject: [PATCH] Fix segmentation fault on first boot. When emu_start() is first called, the Uxn struct is uninitialised stack data. This meant the u->ram pointer would be an invalid address so the program would crash with a segmentation fault when attempting to free it. By setting it to NULL, we avoid this because calling free() on a NULL pointer is a no-op. --- src/uxn11.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uxn11.c b/src/uxn11.c index 15adf5d..f2cda7f 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -227,6 +227,7 @@ main(int argc, char **argv) if(argc < 2) return emu_error("Usage", "uxncli game.rom args"); /* start sequence */ + u.ram = NULL; if(!emu_start(&u, argv[1])) return emu_error("Start", "Failed"); if(!init())