[PATCH 1/2] scrrun: Check for null arguments in MoveFile.

Robert Wilhelm robert.wilhelm at gmx.net
Wed May 25 07:53:11 CDT 2022


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

diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index d7ad255e517..35b43e2f124 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -3758,6 +3758,9 @@ static HRESULT WINAPI filesys_MoveFile(IFileSystem3 *iface, BSTR source, BSTR de
 {
     TRACE("%p %s %s\n", iface, debugstr_w(source), debugstr_w(destination));

+    if(!source || !destination)
+        return E_INVALIDARG;
+
     return MoveFileW(source, destination) ? S_OK : create_error(GetLastError());
 }

diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index 79af87591ff..1ba0e81a2d1 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -2591,6 +2591,13 @@ static void test_MoveFile(void)
     hr = IFileSystem3_DeleteFile(fs3, str, VARIANT_TRUE);
     ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
     SysFreeString(str);
+
+    str = SysAllocString(L"null.txt");
+    hr = IFileSystem3_MoveFile(fs3, str, NULL);
+    ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
+    hr = IFileSystem3_MoveFile(fs3, NULL, str);
+    ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
+    SysFreeString(str);
 }

 static void test_DoOpenPipeStream(void)
--
2.36.1





More information about the wine-devel mailing list