From 658856b256d4e6c255a25ecdd6d1a37d3626877b Mon Sep 17 00:00:00 2001 From: StapleButter Date: Sat, 27 Oct 2018 14:44:39 +0200 Subject: fix implementation of CoTaskMemRealloc, as it can decide to move the buffer elsewhere, we have to account for that --- src/Config.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Config.cpp b/src/Config.cpp index be9e53f..fea92e9 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -139,7 +139,9 @@ FILE* GetConfigFile(const char* fileName, const char* permissions) if (res != fnlen) { delete[] wfileName; return NULL; } // checkme? int pos = wcslen(appDataPath); - CoTaskMemRealloc(appDataPath, (pos+wcslen(appdir)+fnlen+1)*sizeof(WCHAR)); + void* ptr = CoTaskMemRealloc(appDataPath, (pos+wcslen(appdir)+fnlen+1)*sizeof(WCHAR)); + if (!ptr) { delete[] wfileName; return NULL; } // oh well + appDataPath = (PWSTR)ptr; wcscpy(&appDataPath[pos], appdir); pos += wcslen(appdir); wcscpy(&appDataPath[pos], wfileName); -- cgit v1.2.3