commit 8993063b126c65e572944ca487f5b980abfcf60d
Author: Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Mon Oct 26 07:35:06 2015 +0100
Commit: Fabian Greffrath <fabian@greffrath.com>
CommitDate: Mon Oct 26 07:36:02 2015 +0100
Add error message for linedefs referencing non-existent sidedefs
This is a severe mapping error that leads to reading invalid memory
and will thus crash sooner or later. Since this cannot be properly
emulated, do what PrBoom+ does and error out with a message instead
of letting the game crash.
Fixes #624
---
src/doom/p_setup.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/doom/p_setup.c b/src/doom/p_setup.c
index 08fed7aa..b5181625 100644
--- a/src/doom/p_setup.c
+++ b/src/doom/p_setup.c
@@ -198,6 +198,14 @@ void P_LoadSegs (int lump)
ldef = &lines[linedef];
li->linedef = ldef;
side = SHORT(ml->side);
+
+ // e6y: check for wrong indexes
+ if ((unsigned)ldef->sidenum[side] >= (unsigned)numsides)
+ {
+ I_Error("P_LoadSegs: linedef %d for seg %d references a non-existent sidedef %d",
+ linedef, i, (unsigned)ldef->sidenum[side]);
+ }
+
li->sidedef = &sides[ldef->sidenum[side]];
li->frontsector = sides[ldef->sidenum[side]].sector;