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
This commit is contained in:
alexey.lysiuk 2018-03-21 13:03:44 +02:00
parent 88bebaec39
commit 92f10febe8
1 changed files with 3 additions and 1 deletions

View File

@ -564,6 +564,8 @@ static void stripwhite (char *str)
static char *igets (void) static char *igets (void)
{ {
assert(PatchPt != nullptr);
char *line; char *line;
if (*PatchPt == '\0' || PatchPt >= PatchFile + PatchSize ) if (*PatchPt == '\0' || PatchPt >= PatchFile + PatchSize )
@ -2550,7 +2552,7 @@ static bool DoDehPatch()
} }
PatchPt = strchr (PatchFile, '\n'); PatchPt = strchr (PatchFile, '\n');
while ((cont = GetLine()) == 1) while (PatchPt != nullptr && (cont = GetLine()) == 1)
{ {
CHECKKEY ("Doom version", dversion) CHECKKEY ("Doom version", dversion)
else CHECKKEY ("Patch format", pversion) else CHECKKEY ("Patch format", pversion)