From e7771fb4f64c223712143a33a9e106c948d86d66 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 24 Jul 2024 13:03:54 -0700 Subject: [PATCH] Fixed memory corruption in SDL_GetPreferredLocales() Fixes https://github.com/libsdl-org/SDL/issues/10362 --- src/locale/SDL_locale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locale/SDL_locale.c b/src/locale/SDL_locale.c index 341bf682868f9..423e0acf52461 100644 --- a/src/locale/SDL_locale.c +++ b/src/locale/SDL_locale.c @@ -50,7 +50,7 @@ static const SDL_Locale * const *build_locales_from_csv_string(char *csv, int *c } slen = ((size_t)(ptr - csv)) + 1; /* SDL_strlen(csv) + 1 */ - alloclen = (num_locales * sizeof(SDL_Locale *)) + (num_locales * sizeof(SDL_Locale)) + slen; + alloclen = ((num_locales + 1) * sizeof(SDL_Locale *)) + (num_locales * sizeof(SDL_Locale)) + slen; retval = (SDL_Locale **)SDL_calloc(1, alloclen); if (!retval) {