msvcp: Set target to null on error in _Open_dir.

Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gijs Vermeulen 2019-01-25 17:51:41 +01:00 committed by Alexandre Julliard
parent 64aba27f6a
commit b51cee00a7
3 changed files with 12 additions and 10 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;
}
@ -15023,7 +15026,6 @@ 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);
if (handle)
WideCharToMultiByte(CP_ACP, 0, target_w, -1, target, MAX_PATH, NULL, NULL);
return handle;