]> git.mxchange.org Git - quix0rs-blobwars.git/commitdiff
Prevent a segmentation fault when using the -map option without specifying a map.
authorGuus Sliepen <guus@debian.org>
Sun, 9 Aug 2015 13:18:27 +0000 (15:18 +0200)
committerGuus Sliepen <guus@debian.org>
Sun, 9 Aug 2015 13:18:27 +0000 (15:18 +0200)
src/main.cpp

index ba11d63bd26d52a40c103e95ccb85e1b9f8b24ea..9516517cae265d62ecc3ef37e7c1ba3ea17c546e 100644 (file)
@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
                else if (strcmp(argv[i], "--help") == 0) showHelp();
                else if (strcmp(argv[i], "-record") == 0) {recordMode = REPLAY_MODE::RECORD; strlcpy(replayData.filename, argv[++i], sizeof replayData.filename);}
                else if (strcmp(argv[i], "-playback") == 0) {recordMode = REPLAY_MODE::PLAYBACK; strlcpy(replayData.filename, argv[++i], sizeof replayData.filename);}
-               else if (strcmp(argv[i], "-map") == 0) {game.setMapName(argv[++i]); requiredSection = SECTION_GAME;}
+               else if (strcmp(argv[i], "-map") == 0) {if (argc > i + 1) {game.setMapName(argv[++i]); requiredSection = SECTION_GAME;}}
                else if (strcmp(argv[i], "-listmaps") == 0) listMaps();
                else if (strcmp(argv[i], "-credits") == 0) requiredSection = SECTION_CREDITS;