mpm engine and ac mem free fixes

remotes/origin/master
Anoop Saldanha 13 years ago committed by Victor Julien
parent 50aba06530
commit 0eaf0b0129

@ -886,6 +886,176 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) {
}
}
if (sh->mpm_hcbd_ctx_ts != NULL || sh->mpm_hcbd_ctx_tc != NULL) {
if (sh->mpm_hcbd_ctx_ts != NULL) {
if (!sh->mpm_hcbd_ctx_ts->global) {
mpm_table[sh->mpm_hcbd_ctx_ts->mpm_type].DestroyCtx(sh->mpm_hcbd_ctx_ts);
SCFree(sh->mpm_hcbd_ctx_ts);
}
sh->mpm_hcbd_ctx_ts = NULL;
}
if (sh->mpm_hcbd_ctx_tc != NULL) {
if (!sh->mpm_hcbd_ctx_tc->global) {
mpm_table[sh->mpm_hcbd_ctx_tc->mpm_type].DestroyCtx(sh->mpm_hcbd_ctx_tc);
SCFree(sh->mpm_hcbd_ctx_tc);
}
sh->mpm_hcbd_ctx_tc = NULL;
}
}
if (sh->mpm_hsbd_ctx_ts != NULL || sh->mpm_hsbd_ctx_tc != NULL) {
if (sh->mpm_hsbd_ctx_ts != NULL) {
if (!sh->mpm_hsbd_ctx_ts->global) {
mpm_table[sh->mpm_hsbd_ctx_ts->mpm_type].DestroyCtx(sh->mpm_hsbd_ctx_ts);
SCFree(sh->mpm_hsbd_ctx_ts);
}
sh->mpm_hsbd_ctx_ts = NULL;
}
if (sh->mpm_hsbd_ctx_tc != NULL) {
if (!sh->mpm_hsbd_ctx_tc->global) {
mpm_table[sh->mpm_hsbd_ctx_tc->mpm_type].DestroyCtx(sh->mpm_hsbd_ctx_tc);
SCFree(sh->mpm_hsbd_ctx_tc);
}
sh->mpm_hsbd_ctx_tc = NULL;
}
}
if (sh->mpm_hhd_ctx_ts != NULL || sh->mpm_hhd_ctx_tc != NULL) {
if (sh->mpm_hhd_ctx_ts != NULL) {
if (!sh->mpm_hhd_ctx_ts->global) {
mpm_table[sh->mpm_hhd_ctx_ts->mpm_type].DestroyCtx(sh->mpm_hhd_ctx_ts);
SCFree(sh->mpm_hhd_ctx_ts);
}
sh->mpm_hhd_ctx_ts = NULL;
}
if (sh->mpm_hhd_ctx_tc != NULL) {
if (!sh->mpm_hhd_ctx_tc->global) {
mpm_table[sh->mpm_hhd_ctx_tc->mpm_type].DestroyCtx(sh->mpm_hhd_ctx_tc);
SCFree(sh->mpm_hhd_ctx_tc);
}
sh->mpm_hhd_ctx_tc = NULL;
}
}
if (sh->mpm_hrhd_ctx_ts != NULL || sh->mpm_hrhd_ctx_tc != NULL) {
if (sh->mpm_hrhd_ctx_ts != NULL) {
if (!sh->mpm_hrhd_ctx_ts->global) {
mpm_table[sh->mpm_hrhd_ctx_ts->mpm_type].DestroyCtx(sh->mpm_hrhd_ctx_ts);
SCFree(sh->mpm_hrhd_ctx_ts);
}
sh->mpm_hrhd_ctx_ts = NULL;
}
if (sh->mpm_hrhd_ctx_tc != NULL) {
if (!sh->mpm_hrhd_ctx_tc->global) {
mpm_table[sh->mpm_hrhd_ctx_tc->mpm_type].DestroyCtx(sh->mpm_hrhd_ctx_tc);
SCFree(sh->mpm_hrhd_ctx_tc);
}
sh->mpm_hrhd_ctx_tc = NULL;
}
}
if (sh->mpm_hmd_ctx_ts != NULL || sh->mpm_hmd_ctx_tc != NULL) {
if (sh->mpm_hmd_ctx_ts != NULL) {
if (!sh->mpm_hmd_ctx_ts->global) {
mpm_table[sh->mpm_hmd_ctx_ts->mpm_type].DestroyCtx(sh->mpm_hmd_ctx_ts);
SCFree(sh->mpm_hmd_ctx_ts);
}
sh->mpm_hmd_ctx_ts = NULL;
}
if (sh->mpm_hmd_ctx_tc != NULL) {
if (!sh->mpm_hmd_ctx_tc->global) {
mpm_table[sh->mpm_hmd_ctx_tc->mpm_type].DestroyCtx(sh->mpm_hmd_ctx_tc);
SCFree(sh->mpm_hmd_ctx_tc);
}
sh->mpm_hmd_ctx_tc = NULL;
}
}
if (sh->mpm_hcd_ctx_ts != NULL || sh->mpm_hcd_ctx_tc != NULL) {
if (sh->mpm_hcd_ctx_ts != NULL) {
if (!sh->mpm_hcd_ctx_ts->global) {
mpm_table[sh->mpm_hcd_ctx_ts->mpm_type].DestroyCtx(sh->mpm_hcd_ctx_ts);
SCFree(sh->mpm_hcd_ctx_ts);
}
sh->mpm_hcd_ctx_ts = NULL;
}
if (sh->mpm_hcd_ctx_tc != NULL) {
if (!sh->mpm_hcd_ctx_tc->global) {
mpm_table[sh->mpm_hcd_ctx_tc->mpm_type].DestroyCtx(sh->mpm_hcd_ctx_tc);
SCFree(sh->mpm_hcd_ctx_tc);
}
sh->mpm_hcd_ctx_tc = NULL;
}
}
if (sh->mpm_hrud_ctx_ts != NULL || sh->mpm_hrud_ctx_tc != NULL) {
if (sh->mpm_hrud_ctx_ts != NULL) {
if (!sh->mpm_hrud_ctx_ts->global) {
mpm_table[sh->mpm_hrud_ctx_ts->mpm_type].DestroyCtx(sh->mpm_hrud_ctx_ts);
SCFree(sh->mpm_hrud_ctx_ts);
}
sh->mpm_hrud_ctx_ts = NULL;
}
if (sh->mpm_hrud_ctx_tc != NULL) {
if (!sh->mpm_hrud_ctx_tc->global) {
mpm_table[sh->mpm_hrud_ctx_tc->mpm_type].DestroyCtx(sh->mpm_hrud_ctx_tc);
SCFree(sh->mpm_hrud_ctx_tc);
}
sh->mpm_hrud_ctx_tc = NULL;
}
}
if (sh->mpm_hsmd_ctx_ts != NULL || sh->mpm_hsmd_ctx_tc != NULL) {
if (sh->mpm_hsmd_ctx_ts != NULL) {
if (!sh->mpm_hsmd_ctx_ts->global) {
mpm_table[sh->mpm_hsmd_ctx_ts->mpm_type].DestroyCtx(sh->mpm_hsmd_ctx_ts);
SCFree(sh->mpm_hsmd_ctx_ts);
}
sh->mpm_hsmd_ctx_ts = NULL;
}
if (sh->mpm_hsmd_ctx_tc != NULL) {
if (!sh->mpm_hsmd_ctx_tc->global) {
mpm_table[sh->mpm_hsmd_ctx_tc->mpm_type].DestroyCtx(sh->mpm_hsmd_ctx_tc);
SCFree(sh->mpm_hsmd_ctx_tc);
}
sh->mpm_hsmd_ctx_tc = NULL;
}
}
if (sh->mpm_hscd_ctx_ts != NULL || sh->mpm_hscd_ctx_tc != NULL) {
if (sh->mpm_hscd_ctx_ts != NULL) {
if (!sh->mpm_hscd_ctx_ts->global) {
mpm_table[sh->mpm_hscd_ctx_ts->mpm_type].DestroyCtx(sh->mpm_hscd_ctx_ts);
SCFree(sh->mpm_hscd_ctx_ts);
}
sh->mpm_hscd_ctx_ts = NULL;
}
if (sh->mpm_hscd_ctx_tc != NULL) {
if (!sh->mpm_hscd_ctx_tc->global) {
mpm_table[sh->mpm_hscd_ctx_tc->mpm_type].DestroyCtx(sh->mpm_hscd_ctx_tc);
SCFree(sh->mpm_hscd_ctx_tc);
}
sh->mpm_hscd_ctx_tc = NULL;
}
}
if (sh->mpm_huad_ctx_ts != NULL || sh->mpm_huad_ctx_tc != NULL) {
if (sh->mpm_huad_ctx_ts != NULL) {
if (!sh->mpm_huad_ctx_ts->global) {
mpm_table[sh->mpm_huad_ctx_ts->mpm_type].DestroyCtx(sh->mpm_huad_ctx_ts);
SCFree(sh->mpm_huad_ctx_ts);
}
sh->mpm_huad_ctx_ts = NULL;
}
if (sh->mpm_huad_ctx_tc != NULL) {
if (!sh->mpm_huad_ctx_tc->global) {
mpm_table[sh->mpm_huad_ctx_tc->mpm_type].DestroyCtx(sh->mpm_huad_ctx_tc);
SCFree(sh->mpm_huad_ctx_tc);
}
sh->mpm_huad_ctx_tc = NULL;
}
}
return;
}

@ -234,6 +234,7 @@ static inline SCACPattern *SCACAllocPattern(MpmCtx *mpm_ctx)
*
* \param mpm_ctx Pointer to the mpm context.
* \param p Pointer to the SCACPattern instance to be freed.
* \param free Free the above pointer or not.
*/
static inline void SCACFreePattern(MpmCtx *mpm_ctx, SCACPattern *p)
{
@ -1174,6 +1175,25 @@ void SCACDestroyCtx(MpmCtx *mpm_ctx)
sizeof(SC_AC_STATE_TYPE_U32) * 256);
}
if (ctx->output_table != NULL) {
uint32_t state_count;
for (state_count = 0; state_count < ctx->state_count; state_count++) {
if (ctx->output_table[state_count].pids != NULL) {
SCFree(ctx->output_table[state_count].pids);
}
}
SCFree(ctx->output_table);
}
if (ctx->pid_pat_list != NULL) {
int i;
for (i = 0; i < (ctx->max_pat_id + 1); i++) {
if (ctx->pid_pat_list[i].cs != NULL)
SCFree(ctx->pid_pat_list[i].cs);
}
SCFree(ctx->pid_pat_list);
}
SCFree(mpm_ctx->ctx);
mpm_ctx->memory_cnt--;
mpm_ctx->memory_size -= sizeof(SCACCtx);
@ -2043,6 +2063,7 @@ static int SCACTest19(void)
printf("1 != %" PRIu32 " ",cnt);
SCACDestroyCtx(&mpm_ctx);
SCACDestroyThreadCtx(&mpm_ctx, &mpm_thread_ctx);
PmqFree(&pmq);
return result;
}

Loading…
Cancel
Save