diff --git a/nsisplugin/IsProcessRunning.c b/nsisplugin/IsProcessRunning.c index fef4cbe..2019750 100644 --- a/nsisplugin/IsProcessRunning.c +++ b/nsisplugin/IsProcessRunning.c @@ -8,7 +8,7 @@ void __cdecl IsProcessRunning(HWND hwndParent, int string_size, TCHAR *variables EXDLL_INIT(); g_hwndParent = hwndParent; - LPTSTR process = (LPTSTR)malloc(string_size * sizeof(TCHAR)); + LPTSTR process = (LPTSTR)LocalAlloc(LPTR, string_size * sizeof(TCHAR)); popstring(process); CharLowerBuffW(process, wcslen(process)); @@ -17,5 +17,5 @@ void __cdecl IsProcessRunning(HWND hwndParent, int string_size, TCHAR *variables wsprintf(buffer, L"%d", pid); pushstring(buffer); - free(process); + LocalFree(process); } diff --git a/shared/LegacyUpdate.h b/shared/LegacyUpdate.h index ce6491d..d757201 100644 --- a/shared/LegacyUpdate.h +++ b/shared/LegacyUpdate.h @@ -1,6 +1,7 @@ #pragma once #include +#include "Registry.h" static LPWSTR _installPath; diff --git a/shared/Registry.c b/shared/Registry.c index cc19f9e..23f5045 100644 --- a/shared/Registry.c +++ b/shared/Registry.c @@ -11,13 +11,13 @@ HRESULT GetRegistryString(HKEY key, LPCWSTR subkeyPath, LPCWSTR valueName, DWORD if (data != NULL && size != NULL) { DWORD length = 512 * sizeof(WCHAR); - LPWSTR buffer = (LPWSTR)malloc(length); + LPWSTR buffer = (LPWSTR)LocalAlloc(LPTR, length); LSTATUS status; do { status = RegQueryValueEx(subkey, valueName, NULL, NULL, (BYTE *)buffer, &length); if (status == ERROR_MORE_DATA) { length += 256 * sizeof(WCHAR); - buffer = (LPWSTR)realloc(buffer, length); + buffer = (LPWSTR)LocalReAlloc(buffer, length, LMEM_MOVEABLE); } else if (status != ERROR_SUCCESS) { hr = HRESULT_FROM_WIN32(status); goto end; diff --git a/shared/VersionInfo.c b/shared/VersionInfo.c index 11787d4..a241a5b 100644 --- a/shared/VersionInfo.c +++ b/shared/VersionInfo.c @@ -17,7 +17,7 @@ HRESULT GetOwnVersion(LPWSTR *version, LPDWORD size) { return HRESULT_FROM_WIN32(GetLastError()); } - LPVOID verInfo = malloc(verInfoSize); + LPVOID verInfo = LocalAlloc(LPTR, verInfoSize); if (!GetFileVersionInfo(filename, verHandle, verInfoSize, verInfo)) { return HRESULT_FROM_WIN32(GetLastError()); } diff --git a/shared/VersionInfo.h b/shared/VersionInfo.h index 5d736e9..ee3f4bd 100644 --- a/shared/VersionInfo.h +++ b/shared/VersionInfo.h @@ -35,6 +35,6 @@ static inline BOOL IsOSVersionOrEarlier(DWORD major, DWORD minor) { HRESULT GetOwnVersion(LPWSTR *version, LPDWORD size); static inline void GetOwnFileName(LPWSTR *filename, LPDWORD size) { - *filename = (LPWSTR)malloc(MAX_PATH); + *filename = (LPWSTR)LocalAlloc(LPTR, MAX_PATH); *size = GetModuleFileName((HMODULE)&__ImageBase, *filename, MAX_PATH); }