From 5acd37d3ee4da0a9a59e859dcbfdc5fab9ceb972 Mon Sep 17 00:00:00 2001 From: sirlemonhead Date: Mon, 28 Oct 2019 19:14:54 +0000 Subject: [PATCH] Fix crash when pressing enter in Holly mode without typing anything (empty string buffer) --- source/exhumed/src/exhumed.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index bca4123b3..df9bf1c91 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -1038,9 +1038,14 @@ void CheckKeys() { char *pToken = strtok(sHollyStr, " "); - // move player to X, Y coordinates - if (!strcmp(pToken, "GOTO")) + 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 { + bHolly = kFalse; + StatusMessage(1, " "); + } + else if (!strcmp(pToken, "GOTO")) + { + // move player to X, Y coordinates int nSprite = PlayerList[0].nSprite; pToken = strtok(NULL, ","); @@ -2423,8 +2428,9 @@ MENU2: CONTROL_ClearButton(gamefunc_Inventory); } } - else + else { SetAirFrame(); + } } if (record_mode == 3 && movefifopos == movefifoend) { levelnew = 0;