From 314e8d5e5147b452831c234b4d56a8a83a7a78f4 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Mon, 11 Jan 2021 12:23:43 +0100 Subject: [PATCH] simplify V_DrawPatchGeneral() overflow guard --- Source/v_video.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Source/v_video.c b/Source/v_video.c index 28d788a6..fb7865de 100644 --- a/Source/v_video.c +++ b/Source/v_video.c @@ -346,14 +346,11 @@ void V_DrawPatchGeneral(int x, int y, int scrn, patch_t *patch, { int topy = y + column->topdelta; // [FG] too high - while (topy < 0) + while (topy < 0 && count) count--, source++, dest += SCREENWIDTH*4, topy++; // [FG] too low, too tall - while (topy + count > SCREENHEIGHT) + while (topy + count > SCREENHEIGHT && count) count--; - // [FG] nothing left to draw? - if (count < 1) - break; } if ((count-=4)>=0) @@ -429,14 +426,11 @@ void V_DrawPatchGeneral(int x, int y, int scrn, patch_t *patch, { int topy = y + column->topdelta; // [FG] too high - while (topy < 0) + while (topy < 0 && count) count--, source++, dest += SCREENWIDTH, topy++; // [FG] too low, too tall - while (topy + count > SCREENHEIGHT) + while (topy + count > SCREENHEIGHT && count) count--; - // [FG] nothing left to draw? - if (count < 1) - break; } if ((count-=4)>=0)