mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-11 16:18:06 -05:00
Clean up a stale foreign handle in winnps.c.
I had set up an event object for signalling incoming connections to the named pipe, and then called handle_add_foreign_event to get that event object watched for connections - but when I closed down the listening pipe, I deleted the event object without also cancelling that foreign-event handle, so that winhandl.c would potentially call the callback for a destroyed object. (cherry picked from commit 6f241cef2c9770abf71349dd59547b3e5b4c0301)
This commit is contained in:
parent
b58a34115a
commit
02893bcba0
@ -32,6 +32,7 @@ struct Socket_named_pipe_server_tag {
|
||||
/* The current named pipe object + attempt to connect to it */
|
||||
HANDLE pipehandle;
|
||||
OVERLAPPED connect_ovl;
|
||||
struct handle *callback_handle; /* winhandl.c's reference */
|
||||
|
||||
/* PuTTY Socket machinery */
|
||||
Plug plug;
|
||||
@ -51,6 +52,8 @@ static void sk_namedpipeserver_close(Socket s)
|
||||
{
|
||||
Named_Pipe_Server_Socket ps = (Named_Pipe_Server_Socket) s;
|
||||
|
||||
if (ps->callback_handle)
|
||||
handle_free(ps->callback_handle);
|
||||
CloseHandle(ps->pipehandle);
|
||||
CloseHandle(ps->connect_ovl.hEvent);
|
||||
sfree(ps->error);
|
||||
@ -220,6 +223,7 @@ Socket new_named_pipe_listener(const char *pipename, Plug plug)
|
||||
ret->psd = NULL;
|
||||
ret->pipename = dupstr(pipename);
|
||||
ret->acl = NULL;
|
||||
ret->callback_handle = NULL;
|
||||
|
||||
assert(strncmp(pipename, "\\\\.\\pipe\\", 9) == 0);
|
||||
assert(strchr(pipename + 9, '\\') == NULL);
|
||||
@ -237,8 +241,9 @@ Socket new_named_pipe_listener(const char *pipename, Plug plug)
|
||||
|
||||
memset(&ret->connect_ovl, 0, sizeof(ret->connect_ovl));
|
||||
ret->connect_ovl.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
handle_add_foreign_event(ret->connect_ovl.hEvent,
|
||||
named_pipe_connect_callback, ret);
|
||||
ret->callback_handle =
|
||||
handle_add_foreign_event(ret->connect_ovl.hEvent,
|
||||
named_pipe_connect_callback, ret);
|
||||
named_pipe_accept_loop(ret, FALSE);
|
||||
|
||||
cleanup:
|
||||
|
Loading…
x
Reference in New Issue
Block a user