From a1266e7353a817633eab5cf0c30f7de7ea319b89 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 9 Nov 2025 20:21:21 +0100 Subject: [PATCH] make sure our custom res fits within MAXVIDMODES 33 are alot so this probably will never be the case (i hope) --- src/sdl/i_video.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 82e27b2f4..3964a829f 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1524,7 +1524,6 @@ void I_SetPalette(RGBA_t *palette) } } - // make sure the canonical resolutions are always available static const struct { const int w, h; @@ -1653,13 +1652,18 @@ static void I_FillScreenResolutionsList(boolean force) // did not find mode from list, make custom resolution if the values somewhat make sense if (needcustom) { - snprintf(desired_resolution, sizeof(desired_resolution), "%dx%d", custom_w, custom_h); + if (list_size < MAXWINMODES) + { + snprintf(desired_resolution, sizeof(desired_resolution), "%dx%d", custom_w, custom_h); - // [FG] if the desired resolution not in the list, append it - windowedModes[list_size].name = strdup(desired_resolution); - windowedModes[list_size].w = custom_w; - windowedModes[list_size].h = custom_h; - list_size++; + // [FG] if the desired resolution not in the list, append it + windowedModes[list_size].name = strdup(desired_resolution); + windowedModes[list_size].w = custom_w; + windowedModes[list_size].h = custom_h; + list_size++; + } + else + CONS_Alert(CONS_ERROR, "Could not set custom resolution!\n"); } }