X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwinplink.c;h=424260000682075516ceb9c4c33c66f0fc1e85a4;hb=90e7bf4228fa74fda1c65cb2597c9d964329f702;hp=fbeb538f4658bcd3e6397fdcd69658350ab7e1e7;hpb=74278dcd646caee3f9317c97be88645b2af0c038;p=PuTTY.git diff --git a/windows/winplink.c b/windows/winplink.c index fbeb538f..42426000 100644 --- a/windows/winplink.c +++ b/windows/winplink.c @@ -29,6 +29,10 @@ void fatalbox(char *p, ...) vfprintf(stderr, p, ap); va_end(ap); fputc('\n', stderr); + if (logctx) { + log_free(logctx); + logctx = NULL; + } cleanup_exit(1); } void modalfatalbox(char *p, ...) @@ -39,6 +43,10 @@ void modalfatalbox(char *p, ...) vfprintf(stderr, p, ap); va_end(ap); fputc('\n', stderr); + if (logctx) { + log_free(logctx); + logctx = NULL; + } cleanup_exit(1); } void connection_fatal(void *frontend, char *p, ...) @@ -49,6 +57,10 @@ void connection_fatal(void *frontend, char *p, ...) vfprintf(stderr, p, ap); va_end(ap); fputc('\n', stderr); + if (logctx) { + log_free(logctx); + logctx = NULL; + } cleanup_exit(1); } void cmdline_error(char *p, ...) @@ -216,7 +228,13 @@ int stdin_gotdata(struct handle *h, void *data, int len) /* * Special case: report read error. */ - fprintf(stderr, "Unable to read from standard input\n"); + char buf[4096]; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, -len, 0, + buf, lenof(buf), NULL); + buf[lenof(buf)-1] = '\0'; + if (buf[strlen(buf)-1] == '\n') + buf[strlen(buf)-1] = '\0'; + fprintf(stderr, "Unable to read from standard input: %s\n", buf); cleanup_exit(0); } noise_ultralight(len); @@ -237,8 +255,14 @@ void stdouterr_sent(struct handle *h, int new_backlog) /* * Special case: report write error. */ - fprintf(stderr, "Unable to write to standard %s\n", - (h == stdout_handle ? "output" : "error")); + char buf[4096]; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, -new_backlog, 0, + buf, lenof(buf), NULL); + buf[lenof(buf)-1] = '\0'; + if (buf[strlen(buf)-1] == '\n') + buf[strlen(buf)-1] = '\0'; + fprintf(stderr, "Unable to write to standard %s: %s\n", + (h == stdout_handle ? "output" : "error"), buf); cleanup_exit(0); } if (connopen && back->connected(backhandle)) {