From ba88986462cfa6aaccd0ef0708c2a0a7e8bd4fe8 Mon Sep 17 00:00:00 2001 From: Kevin Shanahan Date: Sun, 21 Apr 2013 10:12:05 +0930 Subject: [PATCH] vis: fix portal stack corruption in ClipStackWinding Need to re-check numpoints before we add a split point. Signed-off-by: Kevin Shanahan --- changelog.txt | 1 + vis/vis.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/changelog.txt b/changelog.txt index 24ba90ad..322757e7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Unreleased * qbsp: fixed surface edge corruption when using skip surfaces * qbsp: added "-noskip" option for troubleshooting skip related problems +* vis: fix portal stack corruption in ClipStackWinding * bsputil: added a "--check" option to check internal data consistency 2013-04-10 TyrUtils v0.7 diff --git a/vis/vis.c b/vis/vis.c index 64480539..d79af645 100644 --- a/vis/vis.c +++ b/vis/vis.c @@ -308,6 +308,13 @@ ClipStackWinding(winding_t *in, pstack_t *stack, plane_t *split) if (sides[i + 1] == SIDE_ON || sides[i + 1] == sides[i]) continue; + if (neww->numpoints == MAX_WINDING_FIXED) { + /* Can't clip, fall back to original */ + FreeStackWinding(neww, stack); + c_noclip++; + return in; + } + // generate a split point p2 = in->points[(i + 1) % in->numpoints];