Explicitly closing logctx on various kinds of error exit means that
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 29 Aug 2006 18:50:07 +0000 (18:50 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 29 Aug 2006 18:50:07 +0000 (18:50 +0000)
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
windows/winplink.c

index cbfdef7..b4fa6da 100644 (file)
@@ -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;
index fbeb538..0819934 100644 (file)
@@ -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, ...)