Commit b51cee00 authored by Gijs Vermeulen's avatar Gijs Vermeulen Committed by Alexandre Julliard

msvcp: Set target to null on error in _Open_dir.

parent 64aba27f
...@@ -1792,7 +1792,7 @@ static void test_tr2_sys__dir_operation(void) ...@@ -1792,7 +1792,7 @@ static void test_tr2_sys__dir_operation(void)
while(lstrlenA(longer_path) < MAX_PATH-1) while(lstrlenA(longer_path) < MAX_PATH-1)
strcat(longer_path, "s"); strcat(longer_path, "s");
ok(lstrlenA(longer_path) == MAX_PATH-1, "tr2_sys__Open_dir(): expect MAX_PATH, got %d\n", lstrlenA(longer_path)); 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; type = err = 0xdeadbeef;
result_handle = NULL; result_handle = NULL;
result_handle = p_tr2_sys__Open_dir(first_file_name, longer_path, &err, &type); 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) ...@@ -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(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); 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); memset(dest, 0, MAX_PATH);
err = type = 0xdeadbeef; err = type = 0xdeadbeef;
result_handle = NULL; result_handle = NULL;
...@@ -1832,7 +1832,7 @@ static void test_tr2_sys__dir_operation(void) ...@@ -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_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); 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; err = type = 0xdeadbeef;
result_handle = file; result_handle = file;
result_handle = p_tr2_sys__Open_dir(first_file_name, "not_exist", &err, &type); 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) ...@@ -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); ok(!*first_file_name, "tr2_sys__Open_dir(): expect: 0, got %s\n", first_file_name);
CreateDirectoryA("empty_dir", NULL); CreateDirectoryA("empty_dir", NULL);
memset(first_file_name, 0, MAX_PATH); memset(first_file_name, 0xff, MAX_PATH);
err = type = 0xdeadbeef; err = type = 0xdeadbeef;
result_handle = file; result_handle = file;
result_handle = p_tr2_sys__Open_dir(first_file_name, "empty_dir", &err, &type); result_handle = p_tr2_sys__Open_dir(first_file_name, "empty_dir", &err, &type);
......
...@@ -938,7 +938,7 @@ static void test_dir_operation(void) ...@@ -938,7 +938,7 @@ static void test_dir_operation(void)
wcscat(longer_path, backslashW); wcscat(longer_path, backslashW);
while(lstrlenW(longer_path) < MAX_PATH-1) while(lstrlenW(longer_path) < MAX_PATH-1)
wcscat(longer_path, sW); 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; type = err = 0xdeadbeef;
result_handle = NULL; result_handle = NULL;
result_handle = p_Open_dir(first_file_name, longer_path, &err, &type); result_handle = p_Open_dir(first_file_name, longer_path, &err, &type);
...@@ -947,7 +947,7 @@ static void test_dir_operation(void) ...@@ -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(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); 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)); memset(dest, 0, sizeof(dest));
err = type = 0xdeadbeef; err = type = 0xdeadbeef;
result_handle = NULL; result_handle = NULL;
...@@ -978,7 +978,7 @@ static void test_dir_operation(void) ...@@ -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_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); 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; err = type = 0xdeadbeef;
result_handle = file; result_handle = file;
result_handle = p_Open_dir(first_file_name, not_existW, &err, &type); result_handle = p_Open_dir(first_file_name, not_existW, &err, &type);
...@@ -988,7 +988,7 @@ static void test_dir_operation(void) ...@@ -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)); ok(!*first_file_name, "_Open_dir(): expect: 0, got %s\n", wine_dbgstr_w(first_file_name));
CreateDirectoryW(empty_dirW, NULL); 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; err = type = 0xdeadbeef;
result_handle = file; result_handle = file;
result_handle = p_Open_dir(first_file_name, empty_dirW, &err, &type); result_handle = p_Open_dir(first_file_name, empty_dirW, &err, &type);
......
...@@ -14976,6 +14976,7 @@ void* __cdecl tr2_sys__Open_dir_wchar(wchar_t* target, wchar_t const* dest, int* ...@@ -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); TRACE("(%p %s %p %p)\n", target, debugstr_w(dest), err_code, type);
if(wcslen(dest) > MAX_PATH - 3) { if(wcslen(dest) > MAX_PATH - 3) {
*err_code = ERROR_BAD_PATHNAME; *err_code = ERROR_BAD_PATHNAME;
*target = '\0';
return NULL; return NULL;
} }
wcscpy(temppath, dest); wcscpy(temppath, dest);
...@@ -14984,12 +14985,14 @@ void* __cdecl tr2_sys__Open_dir_wchar(wchar_t* target, wchar_t const* dest, int* ...@@ -14984,12 +14985,14 @@ void* __cdecl tr2_sys__Open_dir_wchar(wchar_t* target, wchar_t const* dest, int*
handle = FindFirstFileW(temppath, &data); handle = FindFirstFileW(temppath, &data);
if(handle == INVALID_HANDLE_VALUE) { if(handle == INVALID_HANDLE_VALUE) {
*err_code = ERROR_BAD_PATHNAME; *err_code = ERROR_BAD_PATHNAME;
*target = '\0';
return NULL; return NULL;
} }
while(!wcscmp(data.cFileName, dot) || !wcscmp(data.cFileName, dotdot)) { while(!wcscmp(data.cFileName, dot) || !wcscmp(data.cFileName, dotdot)) {
if(!FindNextFileW(handle, &data)) { if(!FindNextFileW(handle, &data)) {
*err_code = ERROR_SUCCESS; *err_code = ERROR_SUCCESS;
*type = status_unknown; *type = status_unknown;
*target = '\0';
FindClose(handle); FindClose(handle);
return NULL; return NULL;
} }
...@@ -15023,8 +15026,7 @@ void* __cdecl tr2_sys__Open_dir(char* target, char const* dest, int* err_code, e ...@@ -15023,8 +15026,7 @@ void* __cdecl tr2_sys__Open_dir(char* target, char const* dest, int* err_code, e
handle = tr2_sys__Open_dir_wchar(target_w, dest ? dest_w : NULL, err_code, type); handle = tr2_sys__Open_dir_wchar(target_w, dest ? dest_w : NULL, err_code, type);
if (handle) WideCharToMultiByte(CP_ACP, 0, target_w, -1, target, MAX_PATH, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, target_w, -1, target, MAX_PATH, NULL, NULL);
return handle; return handle;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment