Skip to content

Commit 7f6f697

Browse files
authored
Fix null pointer dereference in traffic_crashlog (#12756)
ServerBacktrace() can return 0 (success) but leave the trace pointer null when the target process has already exited. This caused a SEGV when fprintf() was called with the null trace pointer. Add a null check before using the trace pointer.
1 parent e5cd67e commit 7f6f697

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/traffic_crashlog/traffic_crashlog.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ crashlog_write_backtrace(FILE *fp, pid_t pid, const crashlog_target &)
109109
return false;
110110
}
111111

112+
if (trace == nullptr) {
113+
fprintf(fp, "Unable to retrieve backtrace: trace is null\n");
114+
return false;
115+
}
116+
112117
fprintf(fp, "%s", trace);
113118
free(trace);
114119
return true;

0 commit comments

Comments
 (0)