From 371ea1951bdf66fa58af984ce1c86f85c5e12b6e Mon Sep 17 00:00:00 2001 From: rls1004 <98nba@naver.com> Date: Mon, 9 Sep 2019 09:57:01 +0000 Subject: [PATCH] uftrace: Fix segfault when using --logfile This patch is to fix segfault in --logfile. If logfd is NULL, set logfd to stderr before calling pr_err(). Fixed: #853 Signed-off-by: MinJeong Kim <98nba@naver.com> --- uftrace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/uftrace.c b/uftrace.c index 536d33b2f..099e8bbef 100644 --- a/uftrace.c +++ b/uftrace.c @@ -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); }