Skip to content

Commit

Permalink
Fix NPE segfault when "verbose" is enabled
Browse files Browse the repository at this point in the history
Prior to revision b606826, 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.
  • Loading branch information
dhgutteridge committed Aug 18, 2020
1 parent 9a8d668 commit 0f5efbb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0f5efbb

Please sign in to comment.