diff options
Diffstat (limited to 'games/sms_sdl/patches/fix_option_parsing.diff')
-rw-r--r-- | games/sms_sdl/patches/fix_option_parsing.diff | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/games/sms_sdl/patches/fix_option_parsing.diff b/games/sms_sdl/patches/fix_option_parsing.diff new file mode 100644 index 0000000000..ee91ec487d --- /dev/null +++ b/games/sms_sdl/patches/fix_option_parsing.diff @@ -0,0 +1,83 @@ +diff -x tags -Naur sms_sdl-0.9.4a-r7.1/sdl/main.c sms_sdl-0.9.4a-r7.1.patched/sdl/main.c +--- sms_sdl-0.9.4a-r7.1/sdl/main.c 2009-10-11 21:49:18.000000000 -0400 ++++ sms_sdl-0.9.4a-r7.1.patched/sdl/main.c 2009-10-12 01:41:24.000000000 -0400 +@@ -42,17 +42,20 @@ + + static int parse_args(int argc, char **argv) + { +- int i; ++ int i, name_set = 0; + + /* default virtual console emulation settings */ + cfg.fm = 0; + cfg.japan = 0; + + cfg.filter = -1; +- strcpy(cfg.game_name, argv[1]); + +- for(i = 2; i < argc; ++i) { +- if(strcasecmp(argv[i], "--fm") == 0) ++ for(i = 1; i < argc; ++i) { ++ if(!name_set && argv[i][0] != '-') { ++ strcpy(cfg.game_name, argv[i]); ++ name_set++; ++ } ++ else if(strcasecmp(argv[i], "--fm") == 0) + cfg.fm = 1; + else if(strcasecmp(argv[i], "--japan") == 0) + cfg.japan = 1; +@@ -86,6 +89,11 @@ + else + printf("WARNING: unknown option '%s'.\n", argv[i]); + } ++ if(!name_set) { ++ printf("ERROR: no ROM filename given\n"); ++ return 0; ++ } ++ + return 1; + } + +@@ -112,13 +120,13 @@ + printf(" --filter <mode>\t render using a filter: "); + for(i = 0; i < sizeof(filters) / sizeof(filters[0]) - 1; ++i) + printf("%s,", filters[i].name); +- printf("%s.", filters[i].name); ++ printf("%s.\n", filters[i].name); + return 1; + } + + memset(&cfg, 0, sizeof(cfg)); + if(!parse_args(argc, argv)) +- return 0; ++ return 1; + + if(sdlsms_init(&cfg)) { + sdlsms_emulate(); +diff -x tags -Naur sms_sdl-0.9.4a-r7.1/sdl/saves.c sms_sdl-0.9.4a-r7.1.patched/sdl/saves.c +--- sms_sdl-0.9.4a-r7.1/sdl/saves.c 2003-07-16 23:20:24.000000000 -0400 ++++ sms_sdl-0.9.4a-r7.1.patched/sdl/saves.c 2009-10-11 22:04:10.000000000 -0400 +@@ -88,6 +88,11 @@ + unzCloseCurrentFile(zf); + unzClose(zf); + ++ /* 20091011 bkw: avoid segfaulting if filename contains no dot */ ++ if(!strrchr(romfile, '.')) { ++ printf("Invalid filename '%s' (no extension), giving up\n", romfile); ++ return 0; ++ } + if(strcasecmp(strrchr(romfile, '.'), ".gg") == 0) + cart.type = TYPE_GG; + else +@@ -126,6 +131,11 @@ + + fclose(fd); + ++ /* 20091011 bkw: avoid segfaulting if filename contains no dot */ ++ if(!strrchr(filename, '.')) { ++ printf("Invalid filename '%s' (no extension), giving up\n", filename); ++ return 0; ++ } + /* Figure out game image type */ + if(strcasecmp(strrchr(filename, '.'), ".gg") == 0) + cart.type = TYPE_GG; |