From 7bfc5fd0ba781cf9ae34393dc4765e4506ee3157 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 29 Aug 2006 18:50:07 +0000 Subject: [PATCH] Explicitly closing logctx on various kinds of error exit means that the log file gets fclosed properly and the critical last few messages might be recoverable from the log file more often... git-svn-id: svn://svn.tartarus.org/sgt/putty@6834 cda61777-01e9-0310-a592-d414129be87e --- unix/uxplink.c | 16 +++++++++++++++- windows/winplink.c | 12 ++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/unix/uxplink.c b/unix/uxplink.c index cbfdef72..b4fa6da1 100644 --- a/unix/uxplink.c +++ b/unix/uxplink.c @@ -25,6 +25,8 @@ #define MAX_STDIN_BACKLOG 4096 +void *logctx; + void fatalbox(char *p, ...) { va_list ap; @@ -33,6 +35,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, ...) @@ -43,6 +49,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, ...) @@ -53,6 +63,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, ...) @@ -556,7 +570,7 @@ int main(int argc, char **argv) int exitcode; int errors; int use_subsystem = 0; - void *ldisc, *logctx; + void *ldisc; long now; fdlist = NULL; diff --git a/windows/winplink.c b/windows/winplink.c index fbeb538f..0819934c 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, ...) -- 2.11.0