From 523e0f71515a61f866f90487938cec3dd173a1f3 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Tue, 14 May 2019 10:25:49 +0200 Subject: [PATCH] Fix free unallocated memory in case OpenCL initialization failed --- src/backend.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/backend.c b/src/backend.c index 0514ec5a2..5ad504460 100644 --- a/src/backend.c +++ b/src/backend.c @@ -5255,20 +5255,23 @@ void backend_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if (backend_ctx->enabled == false) return; + hcfree (backend_ctx->devices_param); + + if (backend_ctx->ocl) + { + hcfree (backend_ctx->opencl_platforms); + hcfree (backend_ctx->opencl_platforms_devices); + hcfree (backend_ctx->opencl_platforms_devices_cnt); + hcfree (backend_ctx->opencl_platforms_name); + hcfree (backend_ctx->opencl_platforms_vendor); + hcfree (backend_ctx->opencl_platforms_vendor_id); + hcfree (backend_ctx->opencl_platforms_version); + } + nvrtc_close (hashcat_ctx); cuda_close (hashcat_ctx); ocl_close (hashcat_ctx); - hcfree (backend_ctx->devices_param); - - hcfree (backend_ctx->opencl_platforms); - hcfree (backend_ctx->opencl_platforms_devices); - hcfree (backend_ctx->opencl_platforms_devices_cnt); - hcfree (backend_ctx->opencl_platforms_name); - hcfree (backend_ctx->opencl_platforms_vendor); - hcfree (backend_ctx->opencl_platforms_vendor_id); - hcfree (backend_ctx->opencl_platforms_version); - memset (backend_ctx, 0, sizeof (backend_ctx_t)); }