shell32: Fix a leak on error path (Coverity).

Signed-off-by: Sven Baars <sbaars@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sven Baars 2020-10-04 18:10:23 +02:00 committed by Alexandre Julliard
parent 94b2db85b6
commit 2dac805244
1 changed files with 4 additions and 1 deletions

View File

@ -1251,7 +1251,10 @@ static HRESULT WINAPI ShellFolder2_GetDisplayNameOf(IShellFolder2* iface,
LPWSTR pwszDosFileName = wine_get_dos_file_name(This->m_pszPath); LPWSTR pwszDosFileName = wine_get_dos_file_name(This->m_pszPath);
if (!pwszDosFileName) return HRESULT_FROM_WIN32(GetLastError()); if (!pwszDosFileName) return HRESULT_FROM_WIN32(GetLastError());
lpName->u.pOleStr = SHAlloc((lstrlenW(pwszDosFileName) + 1) * sizeof(WCHAR)); lpName->u.pOleStr = SHAlloc((lstrlenW(pwszDosFileName) + 1) * sizeof(WCHAR));
if (!lpName->u.pOleStr) return HRESULT_FROM_WIN32(GetLastError()); if (!lpName->u.pOleStr) {
heap_free(pwszDosFileName);
return HRESULT_FROM_WIN32(GetLastError());
}
lstrcpyW(lpName->u.pOleStr, pwszDosFileName); lstrcpyW(lpName->u.pOleStr, pwszDosFileName);
PathRemoveBackslashW(lpName->u.pOleStr); PathRemoveBackslashW(lpName->u.pOleStr);
heap_free(pwszDosFileName); heap_free(pwszDosFileName);