From cc92d31eeaa40ae966196cfa5402474ffda0bbc7 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 10 Oct 2009 01:02:58 +0000 Subject: Don't crash when using the donut special type and the joining linedef is one sided (thanks Alexander Waldmann). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1711 --- src/p_spec.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/p_spec.c b/src/p_spec.c index 27042b5d..5bb6f19d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1199,6 +1199,24 @@ int EV_DoDonut(line_t* line) rtn = 1; s2 = getNextSector(s1->lines[0],s1); + + // Vanilla Doom does not check if the linedef is one sided. The + // game does not crash, but reads invalid memory and causes the + // sector floor to move "down" to some unknown height. + // DOSbox prints a warning about an invalid memory access. + // + // I'm not sure exactly what invalid memory is being read. This + // isn't something that should be done, anyway. + // Just print a warning and return. + + if (s2 == NULL) + { + fprintf(stderr, + "EV_DoDonut: linedef had no second sidedef! " + "Unexpected behavior may occur in Vanilla Doom. \n"); + break; + } + for (i = 0;i < s2->linecount;i++) { if ((!s2->lines[i]->flags & ML_TWOSIDED) || -- cgit v1.2.3