From 59571b5aa422f144605e171ddfc36d22add33707 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 25 Aug 2019 08:10:30 +0200 Subject: [PATCH] Guard against aspect ratio index being out of bounds --- retroarch.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/retroarch.c b/retroarch.c index 72a5a09307..ec94f16fcd 100644 --- a/retroarch.c +++ b/retroarch.c @@ -17754,8 +17754,15 @@ static bool video_driver_init_internal(bool *video_is_threaded) (float)custom_vp->width / custom_vp->height : default_aspect; } - video_driver_set_aspect_ratio_value( - aspectratio_lut[settings->uints.video_aspect_ratio_idx].value); + { + /* Guard against aspect ratio index possibly being out of bounds */ + unsigned new_aspect_idx = settings->uints.video_aspect_ratio_idx; + if (new_aspect_idx > ASPECT_RATIO_END) + new_aspect_idx = settings->uints.video_aspect_ratio_idx = 0; + + video_driver_set_aspect_ratio_value( + aspectratio_lut[new_aspect_idx].value); + } if (settings->bools.video_fullscreen|| retroarch_is_forced_fullscreen()) {