From cc052ed02c643f52fade222b796857663b4857bd Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Mon, 17 Oct 2022 00:27:52 +0100 Subject: [PATCH] Fixed a small bug in the clip render rect function where it doesn't check to make sure the src rect pointer isn't NULL. --- src/GameEngine.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/GameEngine.c b/src/GameEngine.c index 7e0fa14..023c4d8 100644 --- a/src/GameEngine.c +++ b/src/GameEngine.c @@ -225,13 +225,23 @@ void fill_rectangle(RenderRect rect, SDL_Color color) { } void clip_render_rects_to_drawing_area(RenderRect *src, RenderRect *dest) { + if (!dest) { + return; + } + WindowDrawingArea area = get_window_drawing_area(); // If the rectangle is completely out of bounds, set its width and height to 0 if (dest->x > area.x + area.width || dest->x + dest->width < area.x || dest->y > area.y + area.height || dest->y + dest->height < area.y) { - src->width = 0.0f; - src->height = 0.0f; + if (src) { + src->width = 0.0f; + src->height = 0.0f; + } + + dest->width = 0.0f; + dest->height = 0.0f; + return; }