From b845fad5e45766fbe51a4c5031f5dbe333a35788 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Sun, 22 Feb 2026 11:32:48 -0500 Subject: [PATCH 1/2] fix uaf --- platforms/sdl/sdl1/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platforms/sdl/sdl1/main.cpp b/platforms/sdl/sdl1/main.cpp index 4e08fc1b9..c6d22e39c 100644 --- a/platforms/sdl/sdl1/main.cpp +++ b/platforms/sdl/sdl1/main.cpp @@ -92,6 +92,7 @@ static std::string getStoragePath() #ifdef _WIN32 pathBase = getenv("APPDATA"); #else + std::string tmp; const char *xdg_data = getenv("XDG_DATA_HOME"); if (xdg_data) pathBase = xdg_data; @@ -104,7 +105,10 @@ static std::string getStoragePath() pathBase = ""; // current working directory } else - pathBase = ((std::string)xdg_data + "/.local/share").c_str(); + { + tmp = (std::string)xdg_data + "/.local/share"; + pathBase = tmp.c_str(); + } } #endif From 5cd72536ab5e22411512fc06d5c6661d714d48fa Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Sun, 22 Feb 2026 18:49:05 -0500 Subject: [PATCH 2/2] redo function --- platforms/sdl/sdl1/main.cpp | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/platforms/sdl/sdl1/main.cpp b/platforms/sdl/sdl1/main.cpp index c6d22e39c..908e535da 100644 --- a/platforms/sdl/sdl1/main.cpp +++ b/platforms/sdl/sdl1/main.cpp @@ -86,36 +86,26 @@ static void initGraphics() static std::string getStoragePath() { - // Doing this as a c-string because worst-case, an SDK - // will return a nullptr instead of an empty string - const char* pathBase; + std::string path; + const char *tmp; #ifdef _WIN32 - pathBase = getenv("APPDATA"); + tmp = getenv("APPDATA"); + if (tmp) + path = tmp; #else - std::string tmp; - const char *xdg_data = getenv("XDG_DATA_HOME"); - if (xdg_data) - pathBase = xdg_data; + tmp = getenv("XDG_DATA_HOME"); + if (tmp) + path = tmp; else { - xdg_data = getenv("HOME"); - if (!xdg_data) - { - LOG_E("HOME not set"); - pathBase = ""; // current working directory - } + tmp = getenv("HOME"); + if (tmp) + path = std::string(tmp) + "/.local/share"; else - { - tmp = (std::string)xdg_data + "/.local/share"; - pathBase = tmp.c_str(); - } + LOG_E("HOME not set"); } #endif - if (!pathBase) - pathBase = ""; // just use the current working directory - - std::string path(pathBase); if (!path.empty()) path += "/"; path += ".reminecraftpe";