ui/nc: Don't segfault if we can't open log_file
authorJeremy Kerr <jk@ozlabs.org>
Tue, 7 May 2013 07:01:53 +0000 (15:01 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 9 May 2013 00:47:54 +0000 (08:47 +0800)
Fallback to logging to /dev/null.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
ui/ncurses/generic-main.c

index 5d8debbbacd09ba3a53c9f49ab7e219f11e386aa..365034ceea3c402d1870e33fa627d80c9fcb4539 100644 (file)
@@ -231,6 +231,9 @@ int main(int argc, char *argv[])
        if (strcmp(opts.log_file, "-")) {
                FILE *log = fopen(opts.log_file, "a");
 
+               if (!log)
+                       log = fopen("/dev/null", "a");
+
                assert(log);
                pb_log_set_stream(log);
        } else