From 0d79250feab71114112287dd8dbec835f4afcd40 Mon Sep 17 00:00:00 2001 From: Xanadrel <1734198+Xanadrel@users.noreply.github.com> Date: Fri, 18 Jun 2021 13:13:16 +0200 Subject: [PATCH] Fix memory leak with status (with brain enabled) --- src/hashcat.c | 4 ++-- src/status.c | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hashcat.c b/src/hashcat.c index 97ee1c725..86c1ba7d6 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1775,6 +1775,8 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st #ifdef WITH_BRAIN hashcat_status->brain_session = status_get_brain_session (hashcat_ctx); hashcat_status->brain_attack = status_get_brain_attack (hashcat_ctx); + hashcat_status->brain_rx_all = status_get_brain_rx_all (hashcat_ctx); + hashcat_status->brain_tx_all = status_get_brain_tx_all (hashcat_ctx); #endif hashcat_status->status_string = status_get_status_string (hashcat_ctx); hashcat_status->status_number = status_get_status_number (hashcat_ctx); @@ -1827,8 +1829,6 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st device_info->brain_link_send_bytes_dev = status_get_brain_link_send_bytes_dev (hashcat_ctx, device_id); device_info->brain_link_recv_bytes_sec_dev = status_get_brain_link_recv_bytes_sec_dev (hashcat_ctx, device_id); device_info->brain_link_send_bytes_sec_dev = status_get_brain_link_send_bytes_sec_dev (hashcat_ctx, device_id); - hashcat_status->brain_rx_all = status_get_brain_rx_all (hashcat_ctx); - hashcat_status->brain_tx_all = status_get_brain_tx_all (hashcat_ctx); #endif } diff --git a/src/status.c b/src/status.c index e445474bf..e424af3b3 100644 --- a/src/status.c +++ b/src/status.c @@ -2268,6 +2268,10 @@ void status_status_destroy (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashca hcfree (hashcat_status->guess_mod); hcfree (hashcat_status->guess_charset); hcfree (hashcat_status->cpt); + #ifdef WITH_BRAIN + hcfree (hashcat_status->brain_rx_all); + hcfree (hashcat_status->brain_tx_all); + #endif hashcat_status->hash_target = NULL; hashcat_status->hash_name = NULL; @@ -2281,6 +2285,10 @@ void status_status_destroy (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashca hashcat_status->guess_mod = NULL; hashcat_status->guess_charset = NULL; hashcat_status->cpt = NULL; + #ifdef WITH_BRAIN + hashcat_status->brain_rx_all = NULL; + hashcat_status->brain_tx_all = NULL; + #endif for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) {