From 43d01f26ea31485821075ba49932a1d649eb063b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 31 Aug 2026 20:32:29 +0800 Subject: [PATCH] Top: handle unknown process names gracefully in output --- src/modules/top/top.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/top/top.c b/src/modules/top/top.c index 8ba755a83..9edbc394d 100644 --- a/src/modules/top/top.c +++ b/src/modules/top/top.c @@ -11,7 +11,12 @@ static void printTopResult(FFTopOptions* options, uint32_t index, uint32_t total ffPrintLogoAndKey(FF_MODULE_GET_DISPLAY_NAME(Top), total == 1 ? 0 : (uint8_t) (index + 1), &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate(); - ffStrbufAppendF(&output, "%s (%u)", process->name.chars, process->pid); + if (process->name.length == 0) { + ffStrbufAppendS(&output, ""); + } else { + ffStrbufAppend(&output, &process->name); + } + ffStrbufAppendF(&output, " (%u)", process->pid); if ((options->showTypes & FF_TOP_TYPE_CPU) && (percentType & FF_PERCENTAGE_TYPE_NUM_BIT)) { ffStrbufAppendS(&output, " - CPU "); ffPercentAppendNum(&output, process->cpuPercent, options->percent, false, &options->moduleArgs);