commit c68645a

james palmer  ·  2022-04-12 15:04:39 +0000 UTC
parent 1acef2a
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.
1 files changed,  +1, -0
+1, -0
1@@ -227,6 +227,7 @@ main(int argc, char **argv)
2 	if(argc < 2)
3 		return emu_error("Usage", "uxncli game.rom args");
4 	/* start sequence */
5+	u.ram = NULL;
6 	if(!emu_start(&u, argv[1]))
7 		return emu_error("Start", "Failed");
8 	if(!init())