mirror of
https://github.com/LegacyUpdate/LegacyUpdate.git
synced 2025-01-22 14:12:07 -05:00
Fix GetOwnVersion() freeing filename too soon
This commit is contained in:
parent
c99bd36cd1
commit
0848263d4f
1 changed files with 5 additions and 2 deletions
|
@ -6,6 +6,8 @@ static LPWSTR _version;
|
|||
|
||||
HRESULT GetOwnVersion(LPWSTR *version) {
|
||||
if (!_loadedOwnVersion) {
|
||||
_loadedOwnVersion = TRUE;
|
||||
|
||||
LPWSTR filename;
|
||||
GetOwnFileName(&filename);
|
||||
|
||||
|
@ -16,14 +18,15 @@ HRESULT GetOwnVersion(LPWSTR *version) {
|
|||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
LocalFree(filename);
|
||||
|
||||
LPVOID verInfo = LocalAlloc(LPTR, verInfoSize);
|
||||
if (!GetFileVersionInfo(filename, verHandle, verInfoSize, verInfo)) {
|
||||
LocalFree(filename);
|
||||
LocalFree(verInfo);
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
LocalFree(filename);
|
||||
|
||||
UINT size;
|
||||
if (!VerQueryValue(verInfo, L"\\StringFileInfo\\040904B0\\ProductVersion", (LPVOID *)&_version, &size)) {
|
||||
LocalFree(verInfo);
|
||||
|
|
Loading…
Reference in a new issue