X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwinsftp.c;h=d061b514843a56d66bbd8d6f4ed91e945b7aa89a;hb=a063e522970946bf7d5dc052079d7773c0dee76d;hp=f37ef2431236d056267dda4adcf51bfde8471b7a;hpb=b6c2346173ee1a8b8cd6ec045bb80243e47400f2;p=PuTTY.git diff --git a/windows/winsftp.c b/windows/winsftp.c index f37ef243..d061b514 100644 --- a/windows/winsftp.c +++ b/windows/winsftp.c @@ -696,6 +696,7 @@ char *ssh_sftp_get_cmdline(char *prompt, int no_fds_ok) int ret; struct command_read_ctx actx, *ctx = &actx; DWORD threadid; + HANDLE hThread; fputs(prompt, stdout); fflush(stdout); @@ -712,8 +713,9 @@ char *ssh_sftp_get_cmdline(char *prompt, int no_fds_ok) ctx->event = CreateEvent(NULL, FALSE, FALSE, NULL); ctx->line = NULL; - if (!CreateThread(NULL, 0, command_read_thread, - ctx, 0, &threadid)) { + hThread = CreateThread(NULL, 0, command_read_thread, ctx, 0, &threadid); + if (!hThread) { + CloseHandle(ctx->event); fprintf(stderr, "Unable to create command input thread\n"); cleanup_exit(1); } @@ -725,6 +727,9 @@ char *ssh_sftp_get_cmdline(char *prompt, int no_fds_ok) assert(ret >= 0); } while (ret == 0); + CloseHandle(hThread); + CloseHandle(ctx->event); + return ctx->line; }