From bddcde73f4f74c5ac040a132e850183d863f1062 Mon Sep 17 00:00:00 2001 From: sirlemonhead Date: Sat, 4 Jan 2020 23:23:39 +0000 Subject: [PATCH] PCExhumed: Cheat code fixes. Default to level 0 if no level number is specified and don't crash if only space characters are submitted. Thanks to NY00123 for reporting. --- source/exhumed/src/exhumed.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 90d7b4d01..77ef4dff8 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -1076,7 +1076,7 @@ void CheckKeys() { char *pToken = strtok(sHollyStr, " "); - if (nStringLen == 0) // bjd - added this check. watcom allows passing NULL to strcmp so the below checks will all fail OK on DOS but will cause a crash on Windows + if (nStringLen == 0 || pToken == NULL) // bjd - added this check. watcom allows passing NULL to strcmp so the below checks will all fail OK on DOS but will cause a crash on Windows { bHolly = kFalse; StatusMessage(1, " "); @@ -1097,7 +1097,12 @@ void CheckKeys() else if (!strcmp(pToken, "LEVEL")) { pToken = strtok(NULL, " "); - levelnew = atoi(pToken); + if (pToken) { + levelnew = atoi(pToken); + } + else { + levelnew = 0; // replicate original DOS EXE behaviour when no level number is specified. + } } else if (!strcmp(pToken, "DOORS")) {