aboutsummaryrefslogtreecommitdiff
path: root/src/libui_sdl
diff options
context:
space:
mode:
Diffstat (limited to 'src/libui_sdl')
-rw-r--r--src/libui_sdl/Platform.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libui_sdl/Platform.cpp b/src/libui_sdl/Platform.cpp
index e47b686..7eba035 100644
--- a/src/libui_sdl/Platform.cpp
+++ b/src/libui_sdl/Platform.cpp
@@ -197,7 +197,10 @@ FILE* OpenLocalFile(const char* path, const char* mode)
PWSTR appDataPath = NULL;
SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &appDataPath);
if (!appDataPath)
+ {
+ delete[] emudirpath;
return NULL;
+ }
// this will be more than enough
WCHAR fatperm[4];
@@ -207,16 +210,16 @@ FILE* OpenLocalFile(const char* path, const char* mode)
fatperm[3] = 0;
int fnlen = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0);
- if (fnlen < 1) return NULL;
+ if (fnlen < 1) { delete[] emudirpath; return NULL; }
WCHAR* wfileName = new WCHAR[fnlen];
int res = MultiByteToWideChar(CP_UTF8, 0, path, -1, wfileName, fnlen);
- if (res != fnlen) { delete[] wfileName; return NULL; } // checkme?
+ if (res != fnlen) { delete[] wfileName; delete[] emudirpath; return NULL; } // checkme?
const WCHAR* appdir = L"\\melonDS\\";
int pos = wcslen(appDataPath);
void* ptr = CoTaskMemRealloc(appDataPath, (pos+wcslen(appdir)+fnlen+1)*sizeof(WCHAR));
- if (!ptr) { delete[] wfileName; return NULL; } // oh well
+ if (!ptr) { delete[] wfileName; delete[] emudirpath; return NULL; } // oh well
appDataPath = (PWSTR)ptr;
wcscpy(&appDataPath[pos], appdir); pos += wcslen(appdir);