Skip to content

Commit

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

Fixed: namhyung#853

Signed-off-by: MinJeong Kim <[email protected]>
  • Loading branch information
rls1004 committed Sep 9, 2019
1 parent 66eb586 commit 371ea19
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 371ea19

Please sign in to comment.