From f392e762f01f50c52a515c95f3d9033b9fd311fe Mon Sep 17 00:00:00 2001 From: VirajMishra1 Date: Wed, 2 Sep 2026 21:04:22 -0400 Subject: [PATCH] fix: division by zero in zstdcli_trace Guard against division by zero when trace data has zero-valued denominators. This can occur when --trace is used with certain inputs. Fixes #4368 --- programs/zstdcli_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/zstdcli_trace.c b/programs/zstdcli_trace.c index f73071a5cf4..e9ce83723d7 100644 --- a/programs/zstdcli_trace.c +++ b/programs/zstdcli_trace.c @@ -82,7 +82,7 @@ static void TRACE_log(char const* method, PTime duration, ZSTD_Trace const* trac int level = 0; int workers = 0; double const durationAsDouble = duration ? (double)duration : .1; - double const ratio = (double)trace->uncompressedSize / (double)trace->compressedSize; + double const ratio = trace->compressedSize ? (double)trace->uncompressedSize / (double)trace->compressedSize : 0.0; double const speed = ((double)trace->uncompressedSize * 1000) / durationAsDouble; if (trace->params) { ZSTD_CCtxParams_getParameter(trace->params, ZSTD_c_compressionLevel, &level);