diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 2fa1e493e..bc17656fb 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -1086,6 +1086,15 @@ void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uin assert(left < right); assert(top < bottom); + if (left >= Width || right <= 0 || top >= Height || bottom <= 0) + { + return; + } + left = MAX(0,left); + right = MIN(Width,right); + top = MAX(0,top); + bottom = MIN(Height,bottom); + if (palcolor < 0) { if (APART(color) != 255) diff --git a/src/v_video.cpp b/src/v_video.cpp index db0be3696..f2436862b 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -348,6 +348,23 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) BYTE *spot; int x, y; + if (x1 >= Width || y1 >= Height) + { + return; + } + if (x1 + w > Width) + { + w = Width - x1; + } + if (y1 + h > Height) + { + h = Height - y1; + } + if (w <= 0 || h <= 0) + { + return; + } + { int amount;