From 7549f2da40d3666f2c9527d84d9ed5468e231691 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 7 Feb 2015 11:48:19 +0000 Subject: [PATCH] Fix handle leak in winhandl.c. The code for cleaning up handle structures works by the main thread asking the per-handle subthread to shut down by means of setting its 'done' flag, and then once the subthread signals back through its event object that it's done so, the main thread frees all its resources and removes the event object from the list of things being checked in the program's event loop. But read threads were not sending back that final event acknowledging a request to shut down, so their event objects were never being cleaned up. Bug spotted by Ronald Weiss. --- windows/winhandl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/windows/winhandl.c b/windows/winhandl.c index b15d1f26..193f24d7 100644 --- a/windows/winhandl.c +++ b/windows/winhandl.c @@ -171,8 +171,10 @@ static DWORD WINAPI handle_input_threadfunc(void *param) break; WaitForSingleObject(ctx->ev_from_main, INFINITE); - if (ctx->done) + if (ctx->done) { + SetEvent(ctx->ev_to_main); break; /* main thread told us to shut down */ + } } if (povl) -- 2.45.2