From d646f95a314a164444d8aaf724a29ba9fcebcf64 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 15 Feb 2018 23:50:38 +0100 Subject: [PATCH] Avoid division by 0 If the frame_size width or height is 0, just return the current size to avoid calculations involving divison by 0. --- app/src/screen.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/screen.c b/app/src/screen.c index 7b871947..9c827738 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -88,6 +88,11 @@ static SDL_bool get_preferred_display_bounds(struct size *bounds) { // - it keeps the aspect ratio // - it scales down to make it fit in the display_size static struct size get_optimal_size(struct size current_size, struct size frame_size) { + if (frame_size.width == 0 || frame_size.height == 0) { + // avoid division by 0 + return current_size; + } + struct size display_size; // 32 bits because we need to multiply two 16 bits values Uint32 w;