From 9b1ce502b88af5a0c7b6ef7e56488893cb9d4f0e Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 14 Feb 2017 16:00:10 +0100 Subject: [PATCH] Hardware Monitor: Fixed several memory leaks in case hash-file writing (in case of --remove) failed --- docs/changes.txt | 1 + src/monitor.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 9867f9186..e4e67f20d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -66,6 +66,7 @@ - Files: Do several file and folder checks on startup rather than when they are actually used to avoid related error after eventual intense operations - Helper: Added functions to check existence, type, read- and write-permissions and rewrite sources to use them instead of stat() - Hardware Monitor: Fixed several memory leaks in case no hardware monitor sensor is found +- Hardware Monitor: Fixed several memory leaks in case hash-file writing (in case of --remove) failed - Mask Increment: Fixed memory leak in case mask_append() fails - OpenCL Device Management: Fixed several memory leaks in case initialization of an OpenCL device or platform failed - Outfile Check: Fixed a memory leak for failed outfile reads diff --git a/src/monitor.c b/src/monitor.c index 176e79a1c..ba593a324 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -102,12 +102,19 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) // these variables are mainly used for fan control - int *fan_speed_chgd = (int *) hccalloc (opencl_ctx->devices_cnt, sizeof (int)); + int fan_speed_chgd[DEVICES_MAX]; + + memset (fan_speed_chgd, 0, sizeof (fan_speed_chgd)); // temperature controller "loopback" values - int *temp_diff_old = (int *) hccalloc (opencl_ctx->devices_cnt, sizeof (int)); - int *temp_diff_sum = (int *) hccalloc (opencl_ctx->devices_cnt, sizeof (int)); + int temp_diff_old[DEVICES_MAX]; + int temp_diff_sum[DEVICES_MAX]; + + memset (temp_diff_old, 0, sizeof (temp_diff_old)); + memset (temp_diff_sum, 0, sizeof (temp_diff_sum)); + + // timer time_t last_temp_check_time; @@ -405,11 +412,6 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if (rc == -1) return -1; } - hcfree (fan_speed_chgd); - - hcfree (temp_diff_old); - hcfree (temp_diff_sum); - return 0; }