Skip to content

Commit

Permalink
- Fixed crash on maps with out of range sidedef and sector numbers, t…
Browse files Browse the repository at this point in the history
…aken from PRBoom.
  • Loading branch information
drfrag666 committed May 29, 2020
1 parent af015f1 commit 642b9fe
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/maploader/maploader.cpp
Expand Up @@ -1759,6 +1759,15 @@ void MapLoader::LoadLineDefs (MapData * map)
if (Level->flags2 & LEVEL2_CLIPMIDTEX) ld->flags |= ML_CLIP_MIDTEX;
if (Level->flags2 & LEVEL2_WRAPMIDTEX) ld->flags |= ML_WRAP_MIDTEX;
if (Level->flags2 & LEVEL2_CHECKSWITCHRANGE) ld->flags |= ML_CHECKSWITCHRANGE;
// cph 2006/09/30 - fix sidedef errors right away.
for (int j=0; j < 2; j++)
{
if (LittleShort(mld->sidenum[j]) != NO_INDEX && mld->sidenum[j] >= Level->sides.Size())
{
mld->sidenum[j] = NO_INDEX;
Printf("Linedef %d has a bad sidedef\n", i);
}
}
}
}

Expand Down Expand Up @@ -2180,11 +2189,11 @@ void MapLoader::LoadSideDefs2 (MapData *map, FMissingTextureTracker &missingtex)
// killough 4/4/98: allow sidedef texture names to be overloaded
// killough 4/11/98: refined to allow colormaps to work as wall
// textures if invalid as colormaps but valid as textures.

// cph 2006/09/30 - catch out-of-range sector numbers; use sector 0 instead
if ((unsigned)LittleShort(msd->sector)>=Level->sectors.Size())
{
Printf (PRINT_HIGH, "Sidedef %d has a bad sector\n", i);
sd->sector = sec = nullptr;
sd->sector = sec = &Level->sectors[0];
}
else
{
Expand Down

0 comments on commit 642b9fe

Please sign in to comment.