From 92f10febe86d0bb39de53711c5926a4609848b7e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 21 Mar 2018 13:03:44 +0200 Subject: [PATCH] Fixed crash on loading malformed DeHackEd patches Lump that contains only "Patch File for DeHackEd v3.0" (without line break at the end) caused a crash --- src/d_dehacked.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 75e873648f..b7587bd2d5 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -564,6 +564,8 @@ static void stripwhite (char *str) static char *igets (void) { + assert(PatchPt != nullptr); + char *line; if (*PatchPt == '\0' || PatchPt >= PatchFile + PatchSize ) @@ -2550,7 +2552,7 @@ static bool DoDehPatch() } PatchPt = strchr (PatchFile, '\n'); - while ((cont = GetLine()) == 1) + while (PatchPt != nullptr && (cont = GetLine()) == 1) { CHECKKEY ("Doom version", dversion) else CHECKKEY ("Patch format", pversion)