mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-09 23:28:06 -05:00
Fix a handle leak in Windows PSFTP.
We were checking the return value of CreateThread for validity, but not keeping it to free afterwards if it _was_ valid. Also, we weren't closing ctx->event in the valid case either. Patch due to Tim Kosse.
This commit is contained in:
parent
fe24f4dfba
commit
02dd708116
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user