X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/385528da29810f6c6f78adbe36543550777c3948..9bf696b19e8cdceb6fe9d3e5a9683f2a04d8bfe1:/plink.c diff --git a/plink.c b/plink.c index b7a2fd4b..a76570ee 100644 --- a/plink.c +++ b/plink.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #define PUTTY_DO_GLOBALS /* actually _define_ globals */ @@ -26,7 +27,7 @@ void fatalbox(char *p, ...) va_end(ap); fputc('\n', stderr); WSACleanup(); - exit(1); + cleanup_exit(1); } void connection_fatal(char *p, ...) { @@ -37,7 +38,7 @@ void connection_fatal(char *p, ...) va_end(ap); fputc('\n', stderr); WSACleanup(); - exit(1); + cleanup_exit(1); } static char *password = NULL; @@ -147,6 +148,8 @@ int from_backend(int is_stderr, char *data, int len) HANDLE h = (is_stderr ? errhandle : outhandle); int osize, esize; + assert(len > 0); + if (is_stderr) { bufchain_add(&stderr_data, data, len); try_output(1); @@ -604,7 +607,7 @@ int main(int argc, char **argv) if (!CreateThread(NULL, 0, stdout_write_thread, &odata, 0, &out_threadid)) { fprintf(stderr, "Unable to create output thread\n"); - exit(1); + cleanup_exit(1); } edata.event = stderrevent; edata.eventback = CreateEvent(NULL, FALSE, FALSE, NULL); @@ -613,7 +616,7 @@ int main(int argc, char **argv) if (!CreateThread(NULL, 0, stdout_write_thread, &edata, 0, &err_threadid)) { fprintf(stderr, "Unable to create error output thread\n"); - exit(1); + cleanup_exit(1); } while (1) { @@ -641,7 +644,7 @@ int main(int argc, char **argv) if (!CreateThread(NULL, 0, stdin_read_thread, &idata, 0, &in_threadid)) { fprintf(stderr, "Unable to create input thread\n"); - exit(1); + cleanup_exit(1); } sending = TRUE; } @@ -722,7 +725,7 @@ int main(int argc, char **argv) odata.busy = 0; if (!odata.writeret) { fprintf(stderr, "Unable to write to standard output\n"); - exit(0); + cleanup_exit(0); } bufchain_consume(&stdout_data, odata.lenwritten); if (bufchain_size(&stdout_data) > 0) @@ -735,7 +738,7 @@ int main(int argc, char **argv) edata.busy = 0; if (!edata.writeret) { fprintf(stderr, "Unable to write to standard output\n"); - exit(0); + cleanup_exit(0); } bufchain_consume(&stderr_data, edata.lenwritten); if (bufchain_size(&stderr_data) > 0)