1
mirror of https://github.com/hashcat/hashcat synced 2024-11-24 14:27:14 +01:00

Fix some memleaks on shutdown

This commit is contained in:
jsteube 2016-09-30 13:36:27 +02:00
parent d2877b95e4
commit af1701c765
18 changed files with 103 additions and 20 deletions

View File

@ -141,7 +141,12 @@ void bitmap_ctx_init (bitmap_ctx_t *bitmap_ctx, const user_options_t *user_optio
void bitmap_ctx_destroy (bitmap_ctx_t *bitmap_ctx)
{
if (bitmap_ctx->enabled == false) return;
if (bitmap_ctx->enabled == false)
{
myfree (bitmap_ctx);
return;
}
bitmap_ctx->bitmap_size = 0;
bitmap_ctx->bitmap_mask = 0;

View File

@ -31,7 +31,12 @@ int combinator_ctx_init (combinator_ctx_t *combinator_ctx, const user_options_t
void combinator_ctx_destroy (combinator_ctx_t *combinator_ctx)
{
if (combinator_ctx->enabled == false) return;
if (combinator_ctx->enabled == false)
{
myfree (combinator_ctx);
return;
}
myfree (combinator_ctx);
}

View File

@ -34,7 +34,12 @@ int cpt_ctx_init (cpt_ctx_t *cpt_ctx, const user_options_t *user_options)
void cpt_ctx_destroy (cpt_ctx_t *cpt_ctx)
{
if (cpt_ctx->enabled == false) return;
if (cpt_ctx->enabled == false)
{
myfree (cpt_ctx);
return;
}
myfree (cpt_ctx->cpt_buf);

View File

@ -50,11 +50,17 @@ int debugfile_init (debugfile_ctx_t *debugfile_ctx, const user_options_t *user_o
void debugfile_destroy (debugfile_ctx_t *debugfile_ctx)
{
if (debugfile_ctx->enabled == false) return;
if (debugfile_ctx->enabled == false)
{
myfree (debugfile_ctx);
if (debugfile_ctx->filename == NULL) return;
return;
}
if (debugfile_ctx->filename)
{
fclose (debugfile_ctx->fp);
}
myfree (debugfile_ctx);
}

View File

@ -50,7 +50,12 @@ void dictstat_init (dictstat_ctx_t *dictstat_ctx, const user_options_t *user_opt
void dictstat_destroy (dictstat_ctx_t *dictstat_ctx)
{
if (dictstat_ctx->enabled == false) return;
if (dictstat_ctx->enabled == false)
{
myfree (dictstat_ctx);
return;
}
myfree (dictstat_ctx->filename);
myfree (dictstat_ctx->base);

View File

@ -409,12 +409,16 @@ int folder_config_init (folder_config_t *folder_config, const char *install_fold
void folder_config_destroy (folder_config_t *folder_config)
{
myfree (folder_config->cpath_real);
myfree (folder_config->cwd);
myfree (folder_config->install_dir);
folder_config->cpath_real = NULL;
folder_config->cwd = NULL;
folder_config->install_dir = NULL;
folder_config->profile_dir = NULL;
folder_config->session_dir = NULL;
folder_config->shared_dir = NULL;
folder_config->cpath_real = NULL;
myfree (folder_config);
}

View File

@ -1525,6 +1525,8 @@ void hashes_destroy (hashes_t *hashes)
hashes->hashes_buf = NULL;
hashes->hash_info = NULL;
myfree (hashes);
}
void hashes_logger (const hashes_t *hashes, const logfile_ctx_t *logfile_ctx)

View File

@ -1269,7 +1269,12 @@ int hwmon_ctx_init (hwmon_ctx_t *hwmon_ctx, const user_options_t *user_options,
void hwmon_ctx_destroy (hwmon_ctx_t *hwmon_ctx, const user_options_t *user_options, const opencl_ctx_t *opencl_ctx)
{
if (hwmon_ctx->enabled == false) return;
if (hwmon_ctx->enabled == false)
{
myfree (hwmon_ctx);
return;
}
// reset default fan speed

View File

@ -117,7 +117,12 @@ void induct_ctx_cleanup (induct_ctx_t *induct_ctx)
void induct_ctx_destroy (induct_ctx_t *induct_ctx)
{
if (induct_ctx->enabled == false) return;
if (induct_ctx->enabled == false)
{
myfree (induct_ctx);
return;
}
if (rmdir (induct_ctx->root_directory) == -1)
{

View File

@ -78,7 +78,12 @@ void logfile_init (logfile_ctx_t *logfile_ctx, const user_options_t *user_option
void logfile_destroy (logfile_ctx_t *logfile_ctx)
{
if (logfile_ctx->enabled == false) return;
if (logfile_ctx->enabled == false)
{
myfree (logfile_ctx);
return;
}
myfree (logfile_ctx->logfile);
myfree (logfile_ctx->topid);

View File

@ -32,7 +32,12 @@ void loopback_init (loopback_ctx_t *loopback_ctx, const user_options_t *user_opt
void loopback_destroy (loopback_ctx_t *loopback_ctx)
{
if (loopback_ctx->enabled == false) return;
if (loopback_ctx->enabled == false)
{
myfree (loopback_ctx);
return;
}
myfree (loopback_ctx->filename);

View File

@ -1507,7 +1507,12 @@ int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_option
void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx)
{
if (opencl_ctx->enabled == false) return;
if (opencl_ctx->enabled == false)
{
myfree (opencl_ctx);
return;
}
myfree (opencl_ctx->devices_param);

View File

@ -143,7 +143,12 @@ void potfile_init (potfile_ctx_t *potfile_ctx, const user_options_t *user_option
void potfile_destroy (potfile_ctx_t *potfile_ctx)
{
if (potfile_ctx->enabled == false) return;
if (potfile_ctx->enabled == false)
{
myfree (potfile_ctx);
return;
}
myfree (potfile_ctx->filename);

View File

@ -406,12 +406,17 @@ void restore_ctx_destroy (restore_ctx_t *restore_ctx)
myfree (restore_ctx->eff_restore_file);
myfree (restore_ctx->new_restore_file);
if (restore_ctx->enabled == false) return;
myfree (restore_ctx->rd);
if (restore_ctx->enabled == false)
{
myfree (restore_ctx);
return;
}
restore_ctx->argc = 0;
restore_ctx->argv = NULL;
myfree (restore_ctx->rd);
myfree (restore_ctx);
}

View File

@ -65,7 +65,12 @@ int straight_ctx_init (straight_ctx_t *straight_ctx, const user_options_t *user_
void straight_ctx_destroy (straight_ctx_t *straight_ctx)
{
if (straight_ctx->enabled == false) return;
if (straight_ctx->enabled == false)
{
myfree (straight_ctx);
return;
}
for (u32 dict_pos = 0; dict_pos < straight_ctx->dicts_cnt; dict_pos++)
{

View File

@ -8,6 +8,7 @@
#include "memory.h"
#include "logging.h"
#include "timer.h"
#include "shared.h"
#include "thread.h"
extern hc_global_data_t data;

View File

@ -241,7 +241,12 @@ int tuning_db_init (tuning_db_t *tuning_db, const user_options_t *user_options,
void tuning_db_destroy (tuning_db_t *tuning_db)
{
if (tuning_db->enabled == false) return;
if (tuning_db->enabled == false)
{
myfree (tuning_db);
return;
}
int i;

View File

@ -439,7 +439,12 @@ void wl_data_init (wl_data_t *wl_data, const user_options_t *user_options, const
void wl_data_destroy (wl_data_t *wl_data)
{
if (wl_data->enabled == false) return;
if (wl_data->enabled == false)
{
myfree (wl_data);
return;
}
myfree (wl_data->buf);