From: Simon Tatham Date: Sat, 20 Dec 2014 18:52:40 +0000 (+0000) Subject: Merge branch 'pre-0.64' X-Git-Tag: 0.68~637 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=23208779e78024a004f5e51c189874cb50c29af0;hp=ae4986a4330cb1a19689521ac3388034849da35f;p=PuTTY.git Merge branch 'pre-0.64' --- diff --git a/psftp.c b/psftp.c index 3543a06e..a8baad6d 100644 --- a/psftp.c +++ b/psftp.c @@ -668,21 +668,19 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart) if (restart) { char decbuf[30]; struct fxp_attrs attrs; - int ret; req = fxp_fstat_send(fh); pktin = sftp_wait_for_reply(req); ret = fxp_fstat_recv(pktin, req, &attrs); if (!ret) { - close_rfile(file); printf("read size of %s: %s\n", outfname, fxp_error()); - return 0; + goto cleanup; } if (!(attrs.flags & SSH_FILEXFER_ATTR_SIZE)) { - close_rfile(file); printf("read size of %s: size was not given\n", outfname); - return 0; + ret = 0; + goto cleanup; } offset = attrs.size; uint64_decimal(offset, decbuf); @@ -735,6 +733,7 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart) xfer_cleanup(xfer); + cleanup: req = fxp_close_send(fh); pktin = sftp_wait_for_reply(req); fxp_close_recv(pktin, req); diff --git a/unix/uxnet.c b/unix/uxnet.c index c3002e43..235d6fd9 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -780,7 +780,7 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i { int s; #ifndef NO_IPV6 - struct addrinfo hints, *ai; + struct addrinfo hints, *ai = NULL; char portstr[6]; #endif union sockaddr_union u; @@ -926,6 +926,12 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i } retcode = bind(s, &addr->sa, addrlen); + +#ifndef NO_IPV6 + if (ai) + freeaddrinfo(ai); +#endif + if (retcode < 0) { close(s); ret->error = strerror(errno); 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; }