From 583849cd2311b50843fcc41fc1bf9574bb24f805 Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 4 Oct 2017 13:04:58 +0200 Subject: [PATCH] Fix missing free() for memory allocated with asprintf() --- src/hashes.c | 15 +++++++++++++++ src/opencl.c | 2 ++ src/shared.c | 4 +++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/hashes.c b/src/hashes.c index 16a8fba97..b6d6db783 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -136,6 +136,9 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) { event_log_error (hashcat_ctx, "%s: %s", new_hashfile, strerror (errno)); + free (new_hashfile); + free (old_hashfile); + return -1; } @@ -145,6 +148,9 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) event_log_error (hashcat_ctx, "%s: %s", new_hashfile, strerror (errno)); + free (new_hashfile); + free (old_hashfile); + return -1; } @@ -211,6 +217,9 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) { event_log_error (hashcat_ctx, "Rename file '%s' to '%s': %s", hashfile, old_hashfile, strerror (errno)); + free (new_hashfile); + free (old_hashfile); + return -1; } @@ -220,11 +229,17 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) { event_log_error (hashcat_ctx, "Rename file '%s' to '%s': %s", new_hashfile, hashfile, strerror (errno)); + free (new_hashfile); + free (old_hashfile); + return -1; } unlink (old_hashfile); + free (new_hashfile); + free (old_hashfile); + return 0; } diff --git a/src/opencl.c b/src/opencl.c index 01d832f07..3cba8172e 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -4458,6 +4458,8 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_opts_update, NULL, NULL); + free (build_opts_update); + //if (CL_rc == -1) return -1; size_t build_log_size = 0; diff --git a/src/shared.c b/src/shared.c index 50a58d4e7..40b87e683 100644 --- a/src/shared.c +++ b/src/shared.c @@ -304,11 +304,13 @@ void setup_environment_variables () if (compute) { - static char *display; + char *display; hc_asprintf (&display, "DISPLAY=%s", compute); putenv (display); + + free (display); } else {