From 08b0cd02e91d4602e8224c301b47c9d670a04c0d Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Wed, 22 Jul 2026 21:59:45 -0700 Subject: [PATCH] perf ui hists: Guard against NULL hist_entry in add_script_opt() In add_script_opt(), when the browser selection has no valid hist_entry (for example, when all entries are filtered out or the trace is empty), hist_browser__selected_entry() returns NULL. Add an explicit check for he == NULL prior to accessing he->time to avoid a potential NULL pointer dereference crash. Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Ian Rogers Signed-off-by: Namhyung Kim --- tools/perf/ui/browsers/hists.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index be8a6b169722..f5e13fc125c6 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -2826,6 +2826,8 @@ add_script_opt(struct hist_browser *browser, time_optstr++; time_act++; } + if (he == NULL) + return n; j = sprintf(tstr, " in "); j += timestamp__scnprintf_usec(he->time, tstr + j, sizeof tstr - j);