From 0ca4ebe1e61a352c5330794fce871f4e3b7a7149 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 26 Sep 2016 15:11:46 +0200 Subject: [PATCH] Do not initialize masks for attack-modes not using masks --- include/types.h | 2 ++ src/mpsp.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/types.h b/include/types.h index a694acc7a..ae6bb3037 100644 --- a/include/types.h +++ b/include/types.h @@ -1116,6 +1116,8 @@ typedef struct typedef struct { + bool enabled; + cs_t mp_sys[6]; cs_t mp_usr[4]; diff --git a/src/mpsp.c b/src/mpsp.c index b1aedd503..124dee207 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -856,6 +856,14 @@ int mask_ctx_init (mask_ctx_t *mask_ctx, const user_options_t *user_options, con { memset (mask_ctx, 0, sizeof (mask_ctx_t)); + mask_ctx->enabled = false; + + if ((user_options->attack_mode != ATTACK_MODE_BF) + && (user_options->attack_mode != ATTACK_MODE_HYBRID1) + && (user_options->attack_mode != ATTACK_MODE_HYBRID2)) return 0; + + mask_ctx->enabled = true; + mask_ctx->root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t)); mask_ctx->markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t)); @@ -1085,6 +1093,8 @@ int mask_ctx_init (mask_ctx_t *mask_ctx, const user_options_t *user_options, con void mask_ctx_destroy (mask_ctx_t *mask_ctx) { + if (mask_ctx->enabled == false) return; + myfree (mask_ctx->css_buf); myfree (mask_ctx->root_css_buf);