X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwinsftp.c;h=d061b514843a56d66bbd8d6f4ed91e945b7aa89a;hb=56a42d09d43e91603f3fbf01f5781bcbbc54a6bd;hp=25ac6c9482079b14e0b1218614f02aa77db2430b;hpb=5c4ce2fadf23bff6f38155df44b5d6040cf80d26;p=PuTTY.git diff --git a/windows/winsftp.c b/windows/winsftp.c index 25ac6c94..d061b514 100644 --- a/windows/winsftp.c +++ b/windows/winsftp.c @@ -495,6 +495,7 @@ int do_eventsel_loop(HANDLE other_event) if (toplevel_callback_pending()) { ticks = 0; + next = now; } else if (run_timers(now, &next)) { then = now; now = GETTICKCOUNT(); @@ -504,6 +505,8 @@ int do_eventsel_loop(HANDLE other_event) ticks = next - now; } else { ticks = INFINITE; + /* no need to initialise next here because we can never get + * WAIT_TIMEOUT */ } handles = handle_get_events(&nhandles); @@ -693,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); @@ -709,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); } @@ -722,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; }