diff --git a/src/util-mpm-ac-bs.c b/src/util-mpm-ac-bs.c index b907eeddc3..4801cba2cc 100644 --- a/src/util-mpm-ac-bs.c +++ b/src/util-mpm-ac-bs.c @@ -479,17 +479,12 @@ static inline void SCACBSCreateDeltaTable(MpmCtx *mpm_ctx) int32_t r_state = 0; if (ctx->state_count < 32767) { - ctx->state_table_u16 = SCMalloc(ctx->state_count * - sizeof(SC_AC_BS_STATE_TYPE_U16) * 256); + ctx->state_table_u16 = SCCalloc(ctx->state_count, sizeof(*ctx->state_table_u16)); if (ctx->state_table_u16 == NULL) { FatalError("Error allocating memory"); } - memset(ctx->state_table_u16, 0, - ctx->state_count * sizeof(SC_AC_BS_STATE_TYPE_U16) * 256); - mpm_ctx->memory_cnt++; - mpm_ctx->memory_size += (ctx->state_count * - sizeof(SC_AC_BS_STATE_TYPE_U16) * 256); + mpm_ctx->memory_size += (ctx->state_count * sizeof(*ctx->state_table_u16)); StateQueue q; memset(&q, 0, sizeof(StateQueue)); @@ -521,17 +516,12 @@ static inline void SCACBSCreateDeltaTable(MpmCtx *mpm_ctx) /* create space for the state table. We could have used the existing goto * table, but since we have it set to hold 32 bit state values, we will create * a new state table here of type SC_AC_BS_STATE_TYPE(current set to uint16_t) */ - ctx->state_table_u32 = SCMalloc(ctx->state_count * - sizeof(SC_AC_BS_STATE_TYPE_U32) * 256); + ctx->state_table_u32 = SCCalloc(ctx->state_count, sizeof(*ctx->state_table_u32)); if (ctx->state_table_u32 == NULL) { FatalError("Error allocating memory"); } - memset(ctx->state_table_u32, 0, - ctx->state_count * sizeof(SC_AC_BS_STATE_TYPE_U32) * 256); - mpm_ctx->memory_cnt++; - mpm_ctx->memory_size += (ctx->state_count * - sizeof(SC_AC_BS_STATE_TYPE_U32) * 256); + mpm_ctx->memory_size += (ctx->state_count * sizeof(*ctx->state_table_u32)); StateQueue q; memset(&q, 0, sizeof(StateQueue));