1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-07-30 02:18:33 +00:00

fix memory leaks

This commit is contained in:
Gabriele Gristina 2025-06-22 21:47:28 +02:00
parent 957f3b8ac9
commit 0720d20cf3
No known key found for this signature in database
GPG Key ID: 9F68B59298F311F0
3 changed files with 39 additions and 20 deletions

View File

@ -8636,6 +8636,11 @@ void backend_ctx_devices_destroy (hashcat_ctx_t *hashcat_ctx)
hcfree (device_param->opencl_device_c_version);
hcfree (device_param->opencl_device_vendor);
}
if (device_param->is_hip == true)
{
hcfree (device_param->gcnArchName);
}
}
backend_ctx->backend_devices_cnt = 0;

View File

@ -44,12 +44,9 @@ void sysfs_cpu_close (void *hashcat_ctx)
char *hm_SYSFS_CPU_get_syspath_hwmon (void)
{
char *found[4];
char *found = NULL;
found[0] = NULL;
found[1] = NULL;
found[2] = NULL;
found[3] = NULL;
int best = 4;
// 16 ok?
@ -61,31 +58,43 @@ char *hm_SYSFS_CPU_get_syspath_hwmon (void)
HCFILE fp;
if (hc_fopen_raw (&fp, path, "rb") == false) continue;
if (hc_fopen_raw (&fp, path, "rb") == false)
{
hcfree (path);
continue;
}
char buf[64] = { 0 };
const size_t line_len = fgetl (&fp, buf, sizeof (buf));
if (line_len)
{
if (strcmp (buf, SENSOR_CORETEMP) == 0) hc_asprintf (&found[0], "%s/hwmon%d", SYSFS_HWMON, i);
if (strcmp (buf, SENSOR_K10TEMP) == 0) hc_asprintf (&found[1], "%s/hwmon%d", SYSFS_HWMON, i);
if (strcmp (buf, SENSOR_K8TEMP) == 0) hc_asprintf (&found[2], "%s/hwmon%d", SYSFS_HWMON, i);
if (strcmp (buf, SENSOR_ACPITZ) == 0) hc_asprintf (&found[3], "%s/hwmon%d", SYSFS_HWMON, i);
}
hc_fclose (&fp);
hcfree (path);
if (line_len == 0) continue;
int tmp_best = -1;
if (strcmp (buf, SENSOR_CORETEMP) == 0) tmp_best = 0;
if (strcmp (buf, SENSOR_K10TEMP) == 0) tmp_best = 1;
if (strcmp (buf, SENSOR_K8TEMP) == 0) tmp_best = 2;
if (strcmp (buf, SENSOR_ACPITZ) == 0) tmp_best = 3;
if (tmp_best >= 0 && tmp_best < best)
{
hcfree (found);
best = tmp_best;
hc_asprintf (&found, "%s/hwmon%d", SYSFS_HWMON, i);
if (best == 0) break;
}
}
if (found[0]) return found[0];
if (found[1]) return found[1];
if (found[2]) return found[2];
if (found[3]) return found[3];
return NULL;
return found;
}
int hm_SYSFS_CPU_get_temperature_current (void *hashcat_ctx, int *val)

View File

@ -324,6 +324,11 @@ void user_options_destroy (hashcat_ctx_t *hashcat_ctx)
hcfree (user_options->rp_files);
if (user_options->backend_info > 0)
{
hcfree (user_options->opencl_device_types);
}
//do not reset this, it might be used from main.c
//memset (user_options, 0, sizeof (user_options_t));
}