From a3a0db447bef3f2de1a19d11cc8a84c4278b323b Mon Sep 17 00:00:00 2001 From: mittorn Date: Sun, 3 Nov 2019 19:09:41 +0700 Subject: [PATCH] ref_soft: draw: check screen bounds in Draw_Fill --- r_draw.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/r_draw.c b/r_draw.c index 6515169d..24ff99f7 100644 --- a/r_draw.c +++ b/r_draw.c @@ -216,12 +216,20 @@ void Draw_Fill (int x, int y, int w, int h) if( x + w > vid.width ) w = vid.width - x; + if( w <= 0 ) + return; + if( y + h > vid.height ) h = vid.height - y; + if( h <= 0 ) + return; + height = h; - if (y < 0) + if( y < 0 ) { + if( h <= -y ) + return; skip = -y; height += y; y = 0;