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.
This commit is contained in:
Victor Julien 2026-05-09 21:12:32 +02:00
parent dc6696ac04
commit 02f6a4fd87

View file

@ -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;
}
}