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:
parent
1acef2aaed
commit
c68645a08f
|
@ -227,6 +227,7 @@ main(int argc, char **argv)
|
||||||
if(argc < 2)
|
if(argc < 2)
|
||||||
return emu_error("Usage", "uxncli game.rom args");
|
return emu_error("Usage", "uxncli game.rom args");
|
||||||
/* start sequence */
|
/* start sequence */
|
||||||
|
u.ram = NULL;
|
||||||
if(!emu_start(&u, argv[1]))
|
if(!emu_start(&u, argv[1]))
|
||||||
return emu_error("Start", "Failed");
|
return emu_error("Start", "Failed");
|
||||||
if(!init())
|
if(!init())
|
||||||
|
|
Loading…
Reference in New Issue