From 6e28963141cf02da2ca108b0104b65fc90b649ff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 17 Apr 2015 19:40:45 +0200 Subject: [PATCH] - added a sanity check to GL nodes loader for a potential crash. --- src/p_glnodes.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index 1b34e8bbc2..547cecace3 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -338,7 +338,14 @@ static bool LoadGLSegs(FileReader * lump) ml->side=LittleShort(ml->side); segs[i].sidedef = ldef->sidedef[ml->side]; - segs[i].frontsector = ldef->sidedef[ml->side]->sector; + if (ldef->sidedef[ml->side] != NULL) + { + segs[i].frontsector = ldef->sidedef[ml->side]->sector; + } + else + { + segs[i].frontsector = NULL; + } if (ldef->flags & ML_TWOSIDED && ldef->sidedef[ml->side^1] != NULL) { segs[i].backsector = ldef->sidedef[ml->side^1]->sector; @@ -346,7 +353,7 @@ static bool LoadGLSegs(FileReader * lump) else { ldef->flags &= ~ML_TWOSIDED; - segs[i].backsector = 0; + segs[i].backsector = NULL; } } @@ -385,7 +392,14 @@ static bool LoadGLSegs(FileReader * lump) ml->side=LittleShort(ml->side); segs[i].sidedef = ldef->sidedef[ml->side]; - segs[i].frontsector = ldef->sidedef[ml->side]->sector; + if (ldef->sidedef[ml->side] != NULL) + { + segs[i].frontsector = ldef->sidedef[ml->side]->sector; + } + else + { + segs[i].frontsector = NULL; + } if (ldef->flags & ML_TWOSIDED && ldef->sidedef[ml->side^1] != NULL) { segs[i].backsector = ldef->sidedef[ml->side^1]->sector; @@ -393,7 +407,7 @@ static bool LoadGLSegs(FileReader * lump) else { ldef->flags &= ~ML_TWOSIDED; - segs[i].backsector = 0; + segs[i].backsector = NULL; } }