Skip to content

Commit

Permalink
uftrace: Fix segfault when given logfile name is already taken by a d…
Browse files Browse the repository at this point in the history
…irectory

This patch is to fix segfault in --logfile.
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 ada5a78
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 ada5a78

Please sign in to comment.