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.
This commit is contained in:
james palmer 2022-04-12 16:04:39 +01:00 committed by neauoire
parent 1acef2aaed
commit c68645a08f
1 changed files with 1 additions and 0 deletions

View File

@ -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())