Skip to content

Commit

Permalink
This patch is to fix segfault in --logfile.
Browse files Browse the repository at this point in the history
If logfd is NULL, set logfd to stderr before calling pr_err().

Fixed: #853
  • Loading branch information
rls1004 committed Sep 9, 2019
1 parent 66eb586 commit 60561dc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion uftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,8 +1082,10 @@ int main(int argc, char *argv[])

if (opts.logfile) {
logfp = fopen(opts.logfile, "a");
if (logfp == NULL)
if (logfp == NULL) {
logfp = stderr;
pr_err("cannot open log file");
}

setvbuf(logfp, NULL, _IOLBF, 1024);
}
Expand Down

0 comments on commit 60561dc

Please sign in to comment.