From 85d68b30bb279bcd5a88b91659a00499a5be743b Mon Sep 17 00:00:00 2001 From: Nikolay Ambartsumov Date: Sun, 20 Feb 2022 05:51:00 +0200 Subject: [PATCH] Fix 3d floor-related crash in software renderer 3d floors can cause the software renderer to set incorrect sprite clipping values that trigger a buffer overflow (and a subsequent crash) when rendering sprites. This commit keeps the clipping values within the view area. --- src/rendering/swrenderer/things/r_visiblesprite.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rendering/swrenderer/things/r_visiblesprite.cpp b/src/rendering/swrenderer/things/r_visiblesprite.cpp index 9d12a83ee..e4b89453c 100644 --- a/src/rendering/swrenderer/things/r_visiblesprite.cpp +++ b/src/rendering/swrenderer/things/r_visiblesprite.cpp @@ -289,6 +289,9 @@ namespace swrenderer hzt = min(hzt, clip3DFloor.sclipTop); } + // Make sure bottom clipping stays within the view size + botclip = min(botclip, viewheight); + if (topclip >= botclip) { spr->Light.BaseColormap = colormap;