[SHELL32] apply similar fixes to SetWorkingDirectory, SetArguments, SetIconLocation and SetRelativePath

svn path=/trunk/; revision=72034
This commit is contained in:
Christoph von Wittich 2016-07-28 15:24:44 +00:00
parent de1219eb52
commit ad14fb5ef9

View file

@ -1342,7 +1342,8 @@ HRESULT WINAPI CShellLink::SetDescription(LPCWSTR pszName)
wcscpy(sDescription, pszName); wcscpy(sDescription, pszName);
} }
else else
sDescription = NULL; sDescription = NULL;
bDirty = TRUE; bDirty = TRUE;
return S_OK; return S_OK;
@ -1365,11 +1366,17 @@ HRESULT WINAPI CShellLink::SetWorkingDirectory(LPCWSTR pszDir)
TRACE("(%p)->(dir=%s)\n", this, debugstr_w(pszDir)); TRACE("(%p)->(dir=%s)\n", this, debugstr_w(pszDir));
HeapFree(GetProcessHeap(), 0, sWorkDir); HeapFree(GetProcessHeap(), 0, sWorkDir);
sWorkDir = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, if (pszDir)
(wcslen(pszDir) + 1) * sizeof (WCHAR)); {
if (!sWorkDir) sWorkDir = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
return E_OUTOFMEMORY; (wcslen(pszDir) + 1) * sizeof (WCHAR));
wcscpy(sWorkDir, pszDir); if (!sWorkDir)
return E_OUTOFMEMORY;
wcscpy(sWorkDir, pszDir);
}
else
sWorkDir = NULL;
bDirty = TRUE; bDirty = TRUE;
return S_OK; return S_OK;
@ -1392,12 +1399,18 @@ HRESULT WINAPI CShellLink::SetArguments(LPCWSTR pszArgs)
TRACE("(%p)->(args=%s)\n", this, debugstr_w(pszArgs)); TRACE("(%p)->(args=%s)\n", this, debugstr_w(pszArgs));
HeapFree(GetProcessHeap(), 0, sArgs); HeapFree(GetProcessHeap(), 0, sArgs);
sArgs = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, if (pszArgs)
(wcslen(pszArgs) + 1) * sizeof (WCHAR)); {
if (!sArgs) sArgs = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
return E_OUTOFMEMORY; (wcslen(pszArgs) + 1) * sizeof (WCHAR));
if (!sArgs)
return E_OUTOFMEMORY;
wcscpy(sArgs, pszArgs);
}
else
sArgs = NULL;
wcscpy(sArgs, pszArgs);
bDirty = TRUE; bDirty = TRUE;
return S_OK; return S_OK;
@ -1478,11 +1491,16 @@ HRESULT WINAPI CShellLink::SetIconLocation(LPCWSTR pszIconPath, INT iIcon)
TRACE("(%p)->(path=%s iicon=%u)\n", this, debugstr_w(pszIconPath), iIcon); TRACE("(%p)->(path=%s iicon=%u)\n", this, debugstr_w(pszIconPath), iIcon);
HeapFree(GetProcessHeap(), 0, sIcoPath); HeapFree(GetProcessHeap(), 0, sIcoPath);
sIcoPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, if (pszIconPath)
(wcslen(pszIconPath) + 1) * sizeof (WCHAR)); {
if (!sIcoPath) sIcoPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
return E_OUTOFMEMORY; (wcslen(pszIconPath) + 1) * sizeof (WCHAR));
wcscpy(sIcoPath, pszIconPath); if (!sIcoPath)
return E_OUTOFMEMORY;
wcscpy(sIcoPath, pszIconPath);
}
else
sIcoPath = NULL;
iIcoNdx = iIcon; iIcoNdx = iIcon;
bDirty = TRUE; bDirty = TRUE;
@ -1495,11 +1513,17 @@ HRESULT WINAPI CShellLink::SetRelativePath(LPCWSTR pszPathRel, DWORD dwReserved)
TRACE("(%p)->(path=%s %x)\n", this, debugstr_w(pszPathRel), dwReserved); TRACE("(%p)->(path=%s %x)\n", this, debugstr_w(pszPathRel), dwReserved);
HeapFree(GetProcessHeap(), 0, sPathRel); HeapFree(GetProcessHeap(), 0, sPathRel);
sPathRel = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, if (pszPathRel)
(wcslen(pszPathRel) + 1) * sizeof (WCHAR)); {
if (!sPathRel) sPathRel = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
return E_OUTOFMEMORY; (wcslen(pszPathRel) + 1) * sizeof (WCHAR));
wcscpy(sPathRel, pszPathRel); if (!sPathRel)
return E_OUTOFMEMORY;
wcscpy(sPathRel, pszPathRel);
}
else
sPathRel = NULL;
bDirty = TRUE; bDirty = TRUE;
return ShellLink_UpdatePath(sPathRel, sPath, sWorkDir, &sPath); return ShellLink_UpdatePath(sPathRel, sPath, sWorkDir, &sPath);