From 552614067235d76f005cd23a5a70b6f71f6607a7 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Mon, 10 Feb 2020 22:30:58 +0000 Subject: [PATCH] Fix SDL_PrefPath on SDL1 for non-Amiga snprintf was used incorrectly - its arguments cannot overlap --- SourceS/sdl2_to_1_2_backports.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SourceS/sdl2_to_1_2_backports.h b/SourceS/sdl2_to_1_2_backports.h index 2e43bfdae..249f200d0 100644 --- a/SourceS/sdl2_to_1_2_backports.h +++ b/SourceS/sdl2_to_1_2_backports.h @@ -881,7 +881,12 @@ inline char *SDL_GetPrefPath(const char *org, const char *app) return NULL; } - SDL_snprintf(retval, len, "%s/", retval); + // Append trailing / + size_t final_len = SDL_strlen(retval); + if (final_len + 1 < len) { + retval[final_len++] = '/'; + retval[final_len] = '\0'; + } return retval; }