server: Fix crash when calling SetNamedPipeHandleState on partially closed pipe.

Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sebastian Lackner 2015-11-23 07:24:07 +01:00 committed by Alexandre Julliard
parent ee02530bc4
commit ace9d329e9
2 changed files with 17 additions and 1 deletions

View File

@ -1427,6 +1427,9 @@ static void test_CloseHandle(void)
ret = GetNamedPipeHandleStateA(hfile, &state, NULL, NULL, NULL, NULL, 0);
ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
state = PIPE_READMODE_MESSAGE | PIPE_WAIT;
ret = SetNamedPipeHandleState(hfile, &state, NULL, NULL);
ok(ret, "SetNamedPipeHandleState failed with %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = ReadFile(hfile, buffer, 0, &numbytes, NULL);
@ -1464,6 +1467,9 @@ static void test_CloseHandle(void)
ret = GetNamedPipeHandleStateA(hfile, &state, NULL, NULL, NULL, NULL, 0);
ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
state = PIPE_READMODE_MESSAGE | PIPE_WAIT;
ret = SetNamedPipeHandleState(hfile, &state, NULL, NULL);
ok(ret, "SetNamedPipeHandleState failed with %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = ReadFile(hfile, buffer, 0, &numbytes, NULL);
@ -1515,6 +1521,9 @@ static void test_CloseHandle(void)
ret = GetNamedPipeHandleStateA(hpipe, &state, NULL, NULL, NULL, NULL, 0);
ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
state = PIPE_READMODE_MESSAGE | PIPE_WAIT;
ret = SetNamedPipeHandleState(hpipe, &state, NULL, NULL);
ok(ret, "SetNamedPipeHandleState failed with %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL);
@ -1552,6 +1561,9 @@ static void test_CloseHandle(void)
ret = GetNamedPipeHandleStateA(hpipe, &state, NULL, NULL, NULL, NULL, 0);
ok(ret, "GetNamedPipeHandleState failed with %u\n", GetLastError());
state = PIPE_READMODE_MESSAGE | PIPE_WAIT;
ret = SetNamedPipeHandleState(hpipe, &state, NULL, NULL);
ok(ret, "SetNamedPipeHandleState failed with %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = ReadFile(hpipe, buffer, 0, &numbytes, NULL);

View File

@ -1046,7 +1046,11 @@ DECL_HANDLER(set_named_pipe_info)
client = (struct pipe_client *)get_handle_obj( current->process, req->handle,
0, &pipe_client_ops );
if (!client) return;
server = client->server;
if (!(server = client->server))
{
release_object( client );
return;
}
}
if ((req->flags & ~(NAMED_PIPE_MESSAGE_STREAM_READ | NAMED_PIPE_NONBLOCKING_MODE)) ||