diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c index 1095279878c..842376a0eb4 100644 --- a/dlls/kernel32/tests/pipe.c +++ b/dlls/kernel32/tests/pipe.c @@ -1387,9 +1387,9 @@ static void test_CreatePipe(void) static void test_CloseHandle(void) { static const char testdata[] = "Hello World"; + DWORD state, numbytes; HANDLE hpipe, hfile; char buffer[32]; - DWORD numbytes; BOOL ret; hpipe = CreateNamedPipeA(PIPENAME, PIPE_ACCESS_DUPLEX, @@ -1425,6 +1425,9 @@ static void test_CloseHandle(void) ok(ret, "ReadFile failed with %u\n", GetLastError()); ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes); + ret = GetNamedPipeHandleStateA(hfile, &state, NULL, NULL, NULL, NULL, 0); + ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError()); + SetLastError(0xdeadbeef); ret = ReadFile(hfile, buffer, 0, &numbytes, NULL); ok(!ret, "ReadFile unexpectedly succeeded\n"); @@ -1459,6 +1462,9 @@ static void test_CloseHandle(void) todo_wine ok(ret, "ReadFile failed with %u\n", GetLastError()); ok(numbytes == 0, "expected 0, got %u\n", numbytes); + ret = GetNamedPipeHandleStateA(hfile, &state, NULL, NULL, NULL, NULL, 0); + ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError()); + SetLastError(0xdeadbeef); ret = ReadFile(hfile, buffer, 0, &numbytes, NULL); ok(!ret, "ReadFile unexpectedly succeeded\n"); @@ -1507,6 +1513,9 @@ static void test_CloseHandle(void) ok(ret, "ReadFile failed with %u\n", GetLastError()); ok(numbytes == sizeof(testdata), "expected sizeof(testdata), got %u\n", numbytes); + ret = GetNamedPipeHandleStateA(hpipe, &state, NULL, NULL, NULL, NULL, 0); + ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError()); + SetLastError(0xdeadbeef); ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL); ok(!ret, "ReadFile unexpectedly succeeded\n"); @@ -1541,6 +1550,9 @@ static void test_CloseHandle(void) todo_wine ok(ret, "ReadFile failed with %u\n", GetLastError()); ok(numbytes == 0, "expected 0, got %u\n", numbytes); + ret = GetNamedPipeHandleStateA(hpipe, &state, NULL, NULL, NULL, NULL, 0); + ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError()); + SetLastError(0xdeadbeef); ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL); ok(!ret, "ReadFile unexpectedly succeeded\n"); diff --git a/server/named_pipe.c b/server/named_pipe.c index fbabc5a53bc..1c9143fadfe 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -1013,11 +1013,14 @@ DECL_HANDLER(get_named_pipe_info) } reply->flags = client ? client->pipe_flags : server->pipe_flags; - reply->sharing = server->pipe->sharing; - reply->maxinstances = server->pipe->maxinstances; - reply->instances = server->pipe->instances; - reply->insize = server->pipe->insize; - reply->outsize = server->pipe->outsize; + if (server) + { + reply->sharing = server->pipe->sharing; + reply->maxinstances = server->pipe->maxinstances; + reply->instances = server->pipe->instances; + reply->insize = server->pipe->insize; + reply->outsize = server->pipe->outsize; + } if (client) release_object(client);