From 535f130891445d82110336d1f67de2f69dd2e5e6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 13 Feb 2014 15:10:01 +0100 Subject: [PATCH] Prevent division by zero in gfx_set_viewport --- gfx/gfx_common.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gfx/gfx_common.c b/gfx/gfx_common.c index 425b6de965..7facb4ca10 100644 --- a/gfx/gfx_common.c +++ b/gfx/gfx_common.c @@ -251,12 +251,14 @@ void gfx_set_config_viewport(void) if (geom->aspect_ratio > 0.0f && g_settings.video.aspect_ratio_auto) aspectratio_lut[ASPECT_RATIO_CONFIG].value = geom->aspect_ratio; else -#ifdef PSP - // Get around division by zero error - aspectratio_lut[ASPECT_RATIO_CONFIG].value = 1.0f; // 1:1 PAR. -#else + { + // Get around division by zero errors + if (geom->base_width == 0) + geom->base_width = 1; + if (geom->base_height == 0) + geom->base_height = 1; aspectratio_lut[ASPECT_RATIO_CONFIG].value = (float)geom->base_width / geom->base_height; // 1:1 PAR. -#endif + } } else aspectratio_lut[ASPECT_RATIO_CONFIG].value = g_settings.video.aspect_ratio;