[PATCH 2/2] msvcp: Set target to null on error in _Open_dir.

Gijs Vermeulen gijsvrm at gmail.com
Fri Jan 25 07:11:22 CST 2019


Signed-off-by: Gijs Vermeulen <gijsvrm at gmail.com>
---
 dlls/msvcp120/tests/msvcp120.c | 8 ++++----
 dlls/msvcp140/tests/msvcp140.c | 8 ++++----
 dlls/msvcp90/ios.c             | 3 +++
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index 6d72f9fd68..534c0151de 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -1792,7 +1792,7 @@ static void test_tr2_sys__dir_operation(void)
     while(lstrlenA(longer_path) < MAX_PATH-1)
         strcat(longer_path, "s");
     ok(lstrlenA(longer_path) == MAX_PATH-1, "tr2_sys__Open_dir(): expect MAX_PATH, got %d\n", lstrlenA(longer_path));
-    memset(first_file_name, 0, MAX_PATH);
+    memset(first_file_name, 0xff, MAX_PATH);
     type = err =  0xdeadbeef;
     result_handle = NULL;
     result_handle = p_tr2_sys__Open_dir(first_file_name, longer_path, &err, &type);
@@ -1801,7 +1801,7 @@ static void test_tr2_sys__dir_operation(void)
     ok(err == ERROR_BAD_PATHNAME, "tr2_sys__Open_dir(): expect: ERROR_BAD_PATHNAME, got %d\n", err);
     ok((int)type == 0xdeadbeef, "tr2_sys__Open_dir(): expect 0xdeadbeef, got %d\n", type);
 
-    memset(first_file_name, 0, MAX_PATH);
+    memset(first_file_name, 0xff, MAX_PATH);
     memset(dest, 0, MAX_PATH);
     err = type = 0xdeadbeef;
     result_handle = NULL;
@@ -1832,7 +1832,7 @@ static void test_tr2_sys__dir_operation(void)
     ok(num_of_sub_dir == 1, "found sub_dir %d times\n", num_of_sub_dir);
     ok(num_of_other_files == 0, "found %d other files\n", num_of_other_files);
 
-    memset(first_file_name, 0, MAX_PATH);
+    memset(first_file_name, 0xff, MAX_PATH);
     err = type = 0xdeadbeef;
     result_handle = file;
     result_handle = p_tr2_sys__Open_dir(first_file_name, "not_exist", &err, &type);
@@ -1842,7 +1842,7 @@ static void test_tr2_sys__dir_operation(void)
     ok(!*first_file_name, "tr2_sys__Open_dir(): expect: 0, got %s\n", first_file_name);
 
     CreateDirectoryA("empty_dir", NULL);
-    memset(first_file_name, 0, MAX_PATH);
+    memset(first_file_name, 0xff, MAX_PATH);
     err = type = 0xdeadbeef;
     result_handle = file;
     result_handle = p_tr2_sys__Open_dir(first_file_name, "empty_dir", &err, &type);
diff --git a/dlls/msvcp140/tests/msvcp140.c b/dlls/msvcp140/tests/msvcp140.c
index 1bae2b914d..b2bdafa4ad 100644
--- a/dlls/msvcp140/tests/msvcp140.c
+++ b/dlls/msvcp140/tests/msvcp140.c
@@ -938,7 +938,7 @@ static void test_dir_operation(void)
     wcscat(longer_path, backslashW);
     while(lstrlenW(longer_path) < MAX_PATH-1)
         wcscat(longer_path, sW);
-    memset(first_file_name, 0, sizeof(first_file_name));
+    memset(first_file_name, 0xff, sizeof(first_file_name));
     type = err =  0xdeadbeef;
     result_handle = NULL;
     result_handle = p_Open_dir(first_file_name, longer_path, &err, &type);
@@ -947,7 +947,7 @@ static void test_dir_operation(void)
     ok(err == ERROR_BAD_PATHNAME, "_Open_dir(): expect: ERROR_BAD_PATHNAME, got %d\n", err);
     ok((int)type == 0xdeadbeef, "_Open_dir(): expect 0xdeadbeef, got %d\n", type);
 
-    memset(first_file_name, 0, sizeof(first_file_name));
+    memset(first_file_name, 0xff, sizeof(first_file_name));
     memset(dest, 0, sizeof(dest));
     err = type = 0xdeadbeef;
     result_handle = NULL;
@@ -978,7 +978,7 @@ static void test_dir_operation(void)
     ok(num_of_sub_dir == 1, "found sub_dir %d times\n", num_of_sub_dir);
     ok(num_of_other_files == 0, "found %d other files\n", num_of_other_files);
 
-    memset(first_file_name, 0, sizeof(first_file_name));
+    memset(first_file_name, 0xff, sizeof(first_file_name));
     err = type = 0xdeadbeef;
     result_handle = file;
     result_handle = p_Open_dir(first_file_name, not_existW, &err, &type);
@@ -988,7 +988,7 @@ static void test_dir_operation(void)
     ok(!*first_file_name, "_Open_dir(): expect: 0, got %s\n", wine_dbgstr_w(first_file_name));
 
     CreateDirectoryW(empty_dirW, NULL);
-    memset(first_file_name, 0, sizeof(first_file_name));
+    memset(first_file_name, 0xff, sizeof(first_file_name));
     err = type = 0xdeadbeef;
     result_handle = file;
     result_handle = p_Open_dir(first_file_name, empty_dirW, &err, &type);
diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c
index 32bd2e7ccd..e5ef024729 100644
--- a/dlls/msvcp90/ios.c
+++ b/dlls/msvcp90/ios.c
@@ -14976,6 +14976,7 @@ void* __cdecl tr2_sys__Open_dir_wchar(wchar_t* target, wchar_t const* dest, int*
     TRACE("(%p %s %p %p)\n", target, debugstr_w(dest), err_code, type);
     if(wcslen(dest) > MAX_PATH - 3) {
         *err_code = ERROR_BAD_PATHNAME;
+        *target = '\0';
         return NULL;
     }
     wcscpy(temppath, dest);
@@ -14984,12 +14985,14 @@ void* __cdecl tr2_sys__Open_dir_wchar(wchar_t* target, wchar_t const* dest, int*
     handle = FindFirstFileW(temppath, &data);
     if(handle == INVALID_HANDLE_VALUE) {
         *err_code = ERROR_BAD_PATHNAME;
+        *target = '\0';
         return NULL;
     }
     while(!wcscmp(data.cFileName, dot) || !wcscmp(data.cFileName, dotdot)) {
         if(!FindNextFileW(handle, &data)) {
             *err_code = ERROR_SUCCESS;
             *type = status_unknown;
+            *target = '\0';
             FindClose(handle);
             return NULL;
         }
-- 
2.20.1




More information about the wine-devel mailing list