shell32: for FO_COPY, if the destination is an empty string, SHFileOperation should use the current directory. Additionally, in parse_file_list, check result of HeapAlloc against NULL.
Lionel Debroux
lionel_debroux at yahoo.fr
Mon Apr 13 05:26:17 CDT 2009
Based on a patch by Nikolay Sivov <bunglehead at gmail.com>.
---
dlls/shell32/shlfileop.c | 12 ++++++++++++
dlls/shell32/tests/shlfileop.c | 14 ++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/dlls/shell32/shlfileop.c b/dlls/shell32/shlfileop.c
index b48e46d..ce76713 100644
--- a/dlls/shell32/shlfileop.c
+++ b/dlls/shell32/shlfileop.c
@@ -1019,6 +1019,8 @@ static HRESULT parse_file_list(FILE_LIST *flList, LPCWSTR szFiles)
flList->feFiles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
flList->num_alloc * sizeof(FILE_ENTRY));
+ if (!flList->feFiles)
+ return E_OUTOFMEMORY;
while (*ptr)
{
@@ -1179,6 +1181,16 @@ static HRESULT copy_files(FILE_OPERATION *op, const FILE_LIST *flFrom, FILE_LIST
const FILE_ENTRY *entryToCopy;
const FILE_ENTRY *fileDest = &flTo->feFiles[0];
+ /* If the destination is empty, SHFileOperation should use the current directory.
+ See bug #13394. */
+ if (!fileDest)
+ {
+ WCHAR currd[MAX_PATH];
+ GetCurrentDirectoryW(MAX_PATH, currd);
+ parse_file_list(flTo, currd);
+ fileDest = &flTo->feFiles[0];
+ }
+
if (flFrom->bAnyDontExist)
return ERROR_SHELL_INTERNAL_FILE_NOT_FOUND;
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c
index 433a131..584cffc 100644
--- a/dlls/shell32/tests/shlfileop.c
+++ b/dlls/shell32/tests/shlfileop.c
@@ -1673,6 +1673,20 @@ static void test_copy(void)
ok(DeleteFileA("ab.txt"), "Expected file to exist\n");
ok(RemoveDirectoryA("one"), "Expected dir to exist\n");
ok(RemoveDirectoryA("two"), "Expected dir to exist\n");
+
+ /* pTo is an empty string */
+ CreateDirectoryA("one", NULL);
+ createTestFile("one\\abcdefghi.abc");
+ shfo.pFrom = "one\\abcdefghi.abc\0";
+ shfo.pTo = "\0";
+ shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI | FOF_FILESONLY |
+ FOF_NOCONFIRMMKDIR;
+
+ retval = SHFileOperationA(&shfo);
+ ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
+ ok(DeleteFileA("abcdefghi.abc"), "Expected file to exist\n");
+ ok(DeleteFileA("one\\abcdefghi.abc"), "Expected file to exist\n");
+ ok(RemoveDirectoryA("one"), "Expected dir to exist\n");
}
/* tests the FO_MOVE action */
--
1.6.3.rc0
--------------010705090800020006070007--
More information about the wine-patches
mailing list