From a7afec3d5da475d18962e3ebdf68e71d532fdbc0 Mon Sep 17 00:00:00 2001 From: xibbert <113959168+xibbert@users.noreply.github.com> Date: Mon, 19 Sep 2022 20:27:34 -0700 Subject: [PATCH] Handle SDL_GetBasePath() returning null. SDL_GetBasePath() returns null on systems that don't implement it. Set to "./" per SDL docs example. --- src/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.c b/src/main.c index 0934f385..073b212e 100644 --- a/src/main.c +++ b/src/main.c @@ -515,10 +515,15 @@ main(int argc, char **argv) char *base_path = SDL_GetBasePath(); + if (!base_path) { + base_path = SDL_strdup("./"); + } + // This causes the emulator to load ROM data from the executable's directory when // no ROM file is specified on the command line. memcpy(rom_path, base_path, strlen(base_path) + 1); strncpy(rom_path + strlen(rom_path), rom_filename, PATH_MAX - strlen(rom_path)); + SDL_free(base_path); argc--; argv++;