]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Fix handle leak in winhandl.c.
authorSimon Tatham <anakin@pobox.com>
Sat, 7 Feb 2015 11:48:19 +0000 (11:48 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 7 Feb 2015 12:50:03 +0000 (12:50 +0000)
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

index b15d1f2620066b4fb4596a418477a26dfac11770..193f24d76a6d529367fdfa57682e7441cb3dcc49 100644 (file)
@@ -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)