Fix some typos and a memory leak in SHFileOperationA.
This commit is contained in:
parent
69361e08b9
commit
b74beada5a
|
@ -613,7 +613,7 @@ LPWSTR SHFileStrCpyCatW(LPWSTR pTo, LPCWSTR pFrom, LPCWSTR pCatStr)
|
||||||
lstrcpyW(&pTo[i_len+1], pCatStr);
|
lstrcpyW(&pTo[i_len+1], pCatStr);
|
||||||
}
|
}
|
||||||
pToFile = StrRChrW(pTo,NULL,'\\');
|
pToFile = StrRChrW(pTo,NULL,'\\');
|
||||||
/* !! termination of the new string-group */
|
/* termination of the new string-group */
|
||||||
pTo[(lstrlenW(pTo)) + 1] = '\0';
|
pTo[(lstrlenW(pTo)) + 1] = '\0';
|
||||||
}
|
}
|
||||||
return pToFile;
|
return pToFile;
|
||||||
|
@ -644,9 +644,9 @@ BOOL SHELL_FileNamesMatch(LPCWSTR pszFiles1, LPCWSTR pszFiles2, BOOL bOnlySrc)
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
*
|
*
|
||||||
* SHName(s)Translate HelperFunction for SHFileOperationA
|
* SHNameTranslate HelperFunction for SHFileOperationA
|
||||||
*
|
*
|
||||||
* Translates a list of 0 terminated ASCI strings into Unicode. If *wString
|
* Translates a list of 0 terminated ASCII strings into Unicode. If *wString
|
||||||
* is NULL, only the necessary size of the string is determined and returned,
|
* is NULL, only the necessary size of the string is determined and returned,
|
||||||
* otherwise the ASCII strings are copied into it and the buffer is increased
|
* otherwise the ASCII strings are copied into it and the buffer is increased
|
||||||
* to point to the location after the final 0 termination char.
|
* to point to the location after the final 0 termination char.
|
||||||
|
@ -690,42 +690,38 @@ DWORD SHNameTranslate(LPWSTR* wString, LPCWSTR* pWToFrom, BOOL more)
|
||||||
DWORD WINAPI SHFileOperationA(LPSHFILEOPSTRUCTA lpFileOp)
|
DWORD WINAPI SHFileOperationA(LPSHFILEOPSTRUCTA lpFileOp)
|
||||||
{
|
{
|
||||||
SHFILEOPSTRUCTW nFileOp = *((LPSHFILEOPSTRUCTW)lpFileOp);
|
SHFILEOPSTRUCTW nFileOp = *((LPSHFILEOPSTRUCTW)lpFileOp);
|
||||||
DWORD retCode = 0, size = 0;
|
DWORD retCode = 0, size;
|
||||||
LPWSTR wString = NULL; /* we change this in SHNameTranslate */
|
LPWSTR ForFree = NULL, /* we change wString in SHNameTranslate and can't use it for freeing */
|
||||||
|
wString = NULL; /* we change this in SHNameTranslate */
|
||||||
|
|
||||||
TRACE("SHFileOperationA");
|
TRACE("SHFileOperationA");
|
||||||
if (FO_DELETE == (nFileOp.wFunc & FO_MASK))
|
if (FO_DELETE == (nFileOp.wFunc & FO_MASK))
|
||||||
nFileOp.pTo = NULL; /* we need a NULL or a valid pointer for translation */
|
nFileOp.pTo = NULL; /* we need a NULL or a valid pointer for translation */
|
||||||
if (!(nFileOp.fFlags & FOF_SIMPLEPROGRESS))
|
if (!(nFileOp.fFlags & FOF_SIMPLEPROGRESS))
|
||||||
nFileOp.lpszProgressTitle = NULL; /* we need a NULL or a valid pointer for translation */
|
nFileOp.lpszProgressTitle = NULL; /* we need a NULL or a valid pointer for translation */
|
||||||
do
|
while (1) /* every loop calculate size, second translate also, if we have storage for this */
|
||||||
{
|
{
|
||||||
if (size)
|
|
||||||
{
|
|
||||||
wString = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
|
|
||||||
if (!wString)
|
|
||||||
{
|
|
||||||
retCode = ERROR_OUTOFMEMORY;
|
|
||||||
nFileOp.fAnyOperationsAborted = TRUE;
|
|
||||||
SetLastError(retCode);
|
|
||||||
return retCode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
size = SHNameTranslate(&wString, &nFileOp.lpszProgressTitle, FALSE); /* no loop */
|
size = SHNameTranslate(&wString, &nFileOp.lpszProgressTitle, FALSE); /* no loop */
|
||||||
size += SHNameTranslate(&wString, &nFileOp.pFrom, TRUE); /* internal loop */
|
size += SHNameTranslate(&wString, &nFileOp.pFrom, TRUE); /* internal loop */
|
||||||
size += SHNameTranslate(&wString, &nFileOp.pTo, TRUE); /* internal loop */
|
size += SHNameTranslate(&wString, &nFileOp.pTo, TRUE); /* internal loop */
|
||||||
/* first loop only for calculate size, no translation, we hav a NULL-pointer */
|
|
||||||
} while (!wString); /* second loop calculate size, also translation. We have a valid pointer */
|
|
||||||
|
|
||||||
retCode = SHFileOperationW(&nFileOp);
|
if (ForFree)
|
||||||
|
{
|
||||||
if (wString)
|
retCode = SHFileOperationW(&nFileOp);
|
||||||
HeapFree(GetProcessHeap(), 0, wString);
|
HeapFree(GetProcessHeap(), 0, ForFree); /* we can not use wString, it was changed */
|
||||||
|
break;
|
||||||
if (retCode)
|
}
|
||||||
{
|
else
|
||||||
nFileOp.fAnyOperationsAborted = TRUE;
|
{
|
||||||
|
wString = ForFree = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
|
||||||
|
if (ForFree) continue;
|
||||||
|
retCode = ERROR_OUTOFMEMORY;
|
||||||
|
nFileOp.fAnyOperationsAborted = TRUE;
|
||||||
|
SetLastError(retCode);
|
||||||
|
return retCode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lpFileOp->hNameMappings = nFileOp.hNameMappings;
|
lpFileOp->hNameMappings = nFileOp.hNameMappings;
|
||||||
lpFileOp->fAnyOperationsAborted = nFileOp.fAnyOperationsAborted;
|
lpFileOp->fAnyOperationsAborted = nFileOp.fAnyOperationsAborted;
|
||||||
return retCode;
|
return retCode;
|
||||||
|
|
Loading…
Reference in New Issue