diff --git a/docs/changes.txt b/docs/changes.txt index bb47ae41d..51cbb4377 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -69,6 +69,7 @@ - Hardware Monitor: Fixed several memory leaks in case hash-file writing (caused by --remove) failed - Mask Increment: Fixed memory leak in case mask_append() fails - OpenCL Device Management: Fixed several memory leaks in case initialization of an OpenCL device or platform failed +- OpenCL Kernel: Move kernel binary buffer from heap to stack memory - Outfile Check: Fixed a memory leak for failed outfile reads - Rule Engine: Fixed several memory leaks in case loading of rules failed - Session Management: Fixed several memory leaks in case profile- or install-folder setup failed diff --git a/src/opencl.c b/src/opencl.c index 66e8eee4d..4e59a1cee 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -4115,9 +4115,13 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) hcmalloc (sizeof (size_t)); + size_t kernel_lengths_buf = 0; - char **kernel_sources = (char **) hcmalloc (sizeof (char *)); + size_t *kernel_lengths = &kernel_lengths_buf; + + char *kernel_sources_buf = NULL; + + char **kernel_sources = &kernel_sources_buf; if (cached == false) { @@ -4200,9 +4204,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; } - hcfree (kernel_lengths); hcfree (kernel_sources[0]); - hcfree (kernel_sources); } /** @@ -4254,9 +4256,13 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) hcmalloc (sizeof (size_t)); + size_t kernel_lengths_buf = 0; - char **kernel_sources = (char **) hcmalloc (sizeof (char *)); + size_t *kernel_lengths = &kernel_lengths_buf; + + char *kernel_sources_buf = NULL; + + char **kernel_sources = &kernel_sources_buf; if (cached == false) { @@ -4339,9 +4345,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; } - hcfree (kernel_lengths); hcfree (kernel_sources[0]); - hcfree (kernel_sources); } // return back to the folder we came from initially (workaround)