Author: khornicek
Date: Thu Mar 11 15:57:05 2010
New Revision: 46098
URL:
http://svn.reactos.org/svn/reactos?rev=46098&view=rev
Log:
[SHELL32]
- partial Wine sync, fixes crashing shlfileop winetest:
Use the current directory when copying to an empty destination.
Fix a memory leak in SHFileOperationW.
Vincent Povirk <vincent at codeweavers dot com>
Modified:
trunk/reactos/dll/win32/shell32/shlfileop.c
Modified: trunk/reactos/dll/win32/shell32/shlfileop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shlfileo…
==============================================================================
--- trunk/reactos/dll/win32/shell32/shlfileop.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/shlfileop.c [iso-8859-1] Thu Mar 11 15:57:05 2010
@@ -1087,6 +1087,20 @@
if (flFrom->bAnyDontExist)
return ERROR_SHELL_INTERNAL_FILE_NOT_FOUND;
+ if (flTo->dwNumFiles == 0)
+ {
+ /* If the destination is empty, SHFileOperation should use the current directory
*/
+ WCHAR curdir[MAX_PATH+1];
+
+ GetCurrentDirectoryW(MAX_PATH, curdir);
+ curdir[lstrlenW(curdir)+1] = 0;
+
+ destroy_file_list(flTo);
+ ZeroMemory(flTo, sizeof(FILE_LIST));
+ parse_file_list(flTo, curdir);
+ fileDest = &flTo->feFiles[0];
+ }
+
if (op->req->fFlags & FOF_MULTIDESTFILES)
{
if (flFrom->bAnyFromWildcard)
@@ -1096,6 +1110,14 @@
{
if (flFrom->dwNumFiles != 1 &&
!IsAttribDir(fileDest->attributes))
return ERROR_CANCELLED;
+
+ /* Free all but the first entry. */
+ for (i = 1; i < flTo->dwNumFiles; i++)
+ {
+ HeapFree(GetProcessHeap(), 0, flTo->feFiles[i].szDirectory);
+ HeapFree(GetProcessHeap(), 0, flTo->feFiles[i].szFilename);
+ HeapFree(GetProcessHeap(), 0, flTo->feFiles[i].szFullPath);
+ }
flTo->dwNumFiles = 1;
}