From 51a5e1cc5142ea6b97f516d6a77b4f787dab1fb9 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 4 Nov 2017 23:20:36 -0700 Subject: [PATCH] Fix a few memory leaks --- src/straight.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/straight.c b/src/straight.c index dfc49602f..7738b063c 100644 --- a/src/straight.c +++ b/src/straight.c @@ -76,6 +76,8 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) const int rc = count_words (hashcat_ctx, fd, straight_ctx->dict, &status_ctx->words_cnt); + fclose (fd); + if (rc == -1) { event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", straight_ctx->dict); @@ -83,8 +85,6 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) return -1; } - fclose (fd); - if (status_ctx->words_cnt == 0) { logfile_sub_msg ("STOP"); @@ -111,14 +111,14 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) const int rc = count_words (hashcat_ctx, fd, combinator_ctx->dict1, &status_ctx->words_cnt); + fclose (fd); + if (rc == -1) { event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", combinator_ctx->dict1); return -1; } - - fclose (fd); } else if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_RIGHT) { @@ -133,14 +133,14 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) const int rc = count_words (hashcat_ctx, fd, combinator_ctx->dict2, &status_ctx->words_cnt); + fclose (fd); + if (rc == -1) { event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", combinator_ctx->dict2); return -1; } - - fclose (fd); } if (status_ctx->words_cnt == 0) @@ -179,6 +179,8 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) const int rc = count_words (hashcat_ctx, fd, straight_ctx->dict, &status_ctx->words_cnt); + fclose (fd); + if (rc == -1) { event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", straight_ctx->dict); @@ -186,8 +188,6 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) return -1; } - fclose (fd); - if (status_ctx->words_cnt == 0) { logfile_sub_msg ("STOP");