mirror of
https://github.com/hashcat/hashcat.git
synced 2024-12-23 23:19:09 +00:00
Merge pull request #559 from matrix/fix_resource_leak
Fix resource leak
This commit is contained in:
commit
a4cf3b4dbc
@ -441,7 +441,12 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
|
||||
const int rc_wl_data_init = wl_data_init (hashcat_ctx_tmp);
|
||||
|
||||
if (rc_wl_data_init == -1) return -1;
|
||||
if (rc_wl_data_init == -1)
|
||||
{
|
||||
fclose (fd);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
u64 words_cur = 0;
|
||||
|
||||
|
11
src/mpsp.c
11
src/mpsp.c
@ -524,7 +524,12 @@ static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr,
|
||||
{
|
||||
const int rc = mp_expand (hashcat_ctx, buf, strlen (buf), mp_sys, mp_usr, index, 1);
|
||||
|
||||
if (rc == -1) return -1;
|
||||
if (rc == -1)
|
||||
{
|
||||
if (fp) fclose (fp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -534,6 +539,8 @@ static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr,
|
||||
|
||||
fclose (fp);
|
||||
|
||||
fp = NULL;
|
||||
|
||||
len = in_superchop (mp_file);
|
||||
|
||||
if (len == 0)
|
||||
@ -552,6 +559,8 @@ static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr,
|
||||
}
|
||||
}
|
||||
|
||||
if (fp) fclose (fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
10
src/opencl.c
10
src/opencl.c
@ -227,6 +227,8 @@ static int read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_fi
|
||||
|
||||
size_t num_read = fread (buf, sizeof (char), st.st_size, fp);
|
||||
|
||||
fclose (fp);
|
||||
|
||||
if (num_read != (size_t) st.st_size)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", kernel_file, strerror (errno));
|
||||
@ -234,8 +236,6 @@ static int read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_fi
|
||||
return -1;
|
||||
}
|
||||
|
||||
fclose (fp);
|
||||
|
||||
buf[st.st_size] = 0;
|
||||
|
||||
for (int i = 0; i < num_devices; i++)
|
||||
@ -3428,18 +3428,18 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
char buf[1];
|
||||
char buf[1] = { 0 };
|
||||
|
||||
size_t n = fread (buf, 1, 1, fd);
|
||||
|
||||
fclose (fd);
|
||||
|
||||
if (n != 1)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: %s", files_names[i], strerror (errno));
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
fclose (fd);
|
||||
}
|
||||
|
||||
// we don't have sm_* on vendors not NV but it doesn't matter
|
||||
|
@ -33,6 +33,8 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
const size_t nread = fread (rd, sizeof (restore_data_t), 1, fp);
|
||||
|
||||
fclose (fp);
|
||||
|
||||
if (nread != 1)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Cannot read %s", eff_restore_file);
|
||||
@ -40,8 +42,6 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
fclose (fp);
|
||||
|
||||
if (rd->pid)
|
||||
{
|
||||
char *pidbin = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin);
|
||||
@ -175,6 +175,8 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Can't read %s", eff_restore_file);
|
||||
|
||||
fclose (fp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -188,6 +190,8 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Can't read %s", eff_restore_file);
|
||||
|
||||
fclose (fp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -248,6 +252,8 @@ static int write_restore (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "setvbuf file '%s': %s", new_restore_file, strerror (errno));
|
||||
|
||||
fclose (fp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user