From 0f5efbb6454bcb97704dd025415df9913c3f83dd Mon Sep 17 00:00:00 2001 From: "David H. Gutteridge" Date: Tue, 18 Aug 2020 17:37:28 -0400 Subject: [PATCH] Fix NPE segfault when "verbose" is enabled Prior to revision b6068265, log_tag() was only ever invoked when err_fp was guaranteed to be assigned. After that revision, it could be called with err_fp being null. Carry some of the old "!verbose" logic into log_tag() to address this. --- actions.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/actions.c b/actions.c index 20458d9..2f44ce7 100644 --- a/actions.c +++ b/actions.c @@ -204,9 +204,10 @@ log_tag(const char *fmt, ...) (void)strftime(now_date, DATELEN, "%b %d %H:%M:%S", &tim); printf("%s", log_action); - fprintf(err_fp, "---%s: %s", now_date, log_action); - fflush(err_fp); - + if (!verbosity) { + fprintf(err_fp, "---%s: %s", now_date, log_action); + fflush(err_fp); + } } static void