From 02f6a4fd8742f3d367af868ebd246b89c08b32ff Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sat, 9 May 2026 21:12:32 +0200 Subject: [PATCH] detect: work around scan-build warning detect-engine.c:2350:69: warning: Out of bound access to memory after the end of 'new_det_ctx' [security.ArrayBound] 2350 | FlowWorkerReplaceDetectCtx(SC_ATOMIC_GET(s->slot_data), new_det_ctx[i]); | ^~~~~~~~~~~~~~ 1 warning generated. --- src/detect-engine.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/detect-engine.c b/src/detect-engine.c index ffda5beea6..66b9697627 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -2283,7 +2283,7 @@ static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx) uint32_t i = 0; /* count detect threads in use */ - uint32_t no_of_detect_tvs = TmThreadCountThreadsByTmmFlags(TM_FLAG_FLOWWORKER_TM); + const uint32_t no_of_detect_tvs = TmThreadCountThreadsByTmmFlags(TM_FLAG_FLOWWORKER_TM); /* can be zero in unix socket mode */ if (no_of_detect_tvs == 0) { return 0; @@ -2347,7 +2347,9 @@ static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx) } SCLogDebug("swapping new det_ctx - %p with older one - %p", new_det_ctx[i], SC_ATOMIC_GET(s->slot_data)); - FlowWorkerReplaceDetectCtx(SC_ATOMIC_GET(s->slot_data), new_det_ctx[i++]); + DEBUG_VALIDATE_BUG_ON(i >= no_of_detect_tvs); // help scan-build + FlowWorkerReplaceDetectCtx(SC_ATOMIC_GET(s->slot_data), new_det_ctx[i]); + i++; break; } }