Skip to content

Commit

Permalink
alert: fixes leak in ThresholdHandlePacketRule
Browse files Browse the repository at this point in the history
ThresholdHandlePacketRule may take ownership of an allocated
DetectThresholdEntry, and places it in a position of the
array th_entry. But it never got released

(cherry picked from commit 6fadb97)
  • Loading branch information
catenacyber authored and inashivb committed Dec 10, 2021
1 parent 9d7630d commit def83c8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/detect-engine-threshold.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,14 @@ void ThresholdHashAllocate(DetectEngineCtx *de_ctx)
*/
void ThresholdContextDestroy(DetectEngineCtx *de_ctx)
{
if (de_ctx->ths_ctx.th_entry != NULL)
if (de_ctx->ths_ctx.th_entry != NULL) {
for (uint32_t i = 0; i < de_ctx->ths_ctx.th_size; i++) {
if (de_ctx->ths_ctx.th_entry[i] != NULL) {
SCFree(de_ctx->ths_ctx.th_entry[i]);
}
}
SCFree(de_ctx->ths_ctx.th_entry);
}
SCMutexDestroy(&de_ctx->ths_ctx.threshold_table_lock);
}

Expand Down

0 comments on commit def83c8

Please sign in to comment.