[PATCH 4/8] scrrun: Check for non-existant source in MoveFolder.

Robert Wilhelm wine at gitlab.winehq.org
Wed Jun 29 10:47:05 CDT 2022


From: Robert Wilhelm <robert.wilhelm at gmx.net>

Signed-off-by: Robert Wilhelm <robert.wilhelm at gmx.net>
---
 dlls/scrrun/filesystem.c       | 6 ++++++
 dlls/scrrun/tests/filesystem.c | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index 815ec934ac1..816d8993530 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -3766,11 +3766,17 @@ static HRESULT WINAPI filesys_MoveFile(IFileSystem3 *iface, BSTR source, BSTR de
 
 static HRESULT WINAPI filesys_MoveFolder(IFileSystem3 *iface, BSTR source, BSTR destination)
 {
+    DWORD attrs;
+
     TRACE("%p %s %s\n", iface, debugstr_w(source), debugstr_w(destination));
 
     if(!source || !destination)
         return E_INVALIDARG;
 
+    attrs = GetFileAttributesW(source);
+    if(attrs == INVALID_FILE_ATTRIBUTES)
+        return CTL_E_PATHNOTFOUND;
+
     return MoveFileW(source, destination) ? S_OK : create_error(GetLastError());
 }
 
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index 5c911172d1a..f2bfe52c2ad 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -2635,6 +2635,13 @@ static void test_MoveFolder(void)
     SysFreeString(dst);
     ok(RemoveDirectoryW(buffW1), "can't remove %s directory\n", wine_dbgstr_w(buffW1));
     ok(RemoveDirectoryW(buffW2), "can't remove %s directory\n", wine_dbgstr_w(buffW2));
+
+    src = SysAllocString(buffW1);
+    dst = SysAllocString(buffW2);
+    hr = IFileSystem3_MoveFolder(fs3, src, dst); /* src nonexistant */
+    ok(hr == CTL_E_PATHNOTFOUND, "Unexpected hr %#lx.\n", hr);
+    SysFreeString(src);
+    SysFreeString(dst);
 }
 
 static void test_DoOpenPipeStream(void)
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/343



More information about the wine-devel mailing list