From ec83318faeef907248d133aa69d54d5d9aad139b Mon Sep 17 00:00:00 2001 From: Brice Videau Date: Wed, 7 Feb 2024 16:59:38 -0600 Subject: [PATCH] Fix memory leaks in loader_test. --- test/driver_stub/cl.c | 4 +++- test/loader_test/test_create_calls.c | 4 ++++ test/loader_test/test_program_objects.c | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test/driver_stub/cl.c b/test/driver_stub/cl.c index 9b78e580..398fee8b 100644 --- a/test/driver_stub/cl.c +++ b/test/driver_stub/cl.c @@ -1835,11 +1835,13 @@ clEnqueueNativeKernel(cl_command_queue command_queue , return return_value; } +static void extFunc(void) { } + CL_API_ENTRY void * CL_API_CALL clGetExtensionFunctionAddressForPlatform(cl_platform_id platform , const char * func_name) CL_API_SUFFIX__VERSION_1_2 { - void *return_value = (void *) malloc(sizeof(void *)); + void *return_value = (void *)(size_t)&extFunc; test_icd_stub_log("clGetExtensionFunctionAddressForPlatform(%p, %p)\n", platform, func_name); diff --git a/test/loader_test/test_create_calls.c b/test/loader_test/test_create_calls.c index 510035f4..3446453e 100644 --- a/test/loader_test/test_create_calls.c +++ b/test/loader_test/test_create_calls.c @@ -780,12 +780,16 @@ int test_create_calls() test_clCreateBuffer(clCreateBufferData); + test_clReleaseMemObject(clReleaseMemObjectData); + test_clCreateBufferWithProperties(clCreateBufferWithPropertiesData); test_clCreateSubBuffer(clCreateSubBufferData); test_clCreateImage(clCreateImageData); + test_clReleaseMemObject(clReleaseMemObjectDataImage); + test_clCreateImageWithProperties(clCreateImageWithPropertiesData); test_clReleaseMemObject(clReleaseMemObjectDataImage); diff --git a/test/loader_test/test_program_objects.c b/test/loader_test/test_program_objects.c index 8e643724..b161d357 100644 --- a/test/loader_test/test_program_objects.c +++ b/test/loader_test/test_program_objects.c @@ -124,6 +124,7 @@ int test_clCompileProgram(const struct clCompileProgram_st *data) int test_clLinkProgram(const struct clLinkProgram_st *data) { cl_program program; + cl_int ret_val; test_icd_app_log("clLinkProgram(%p, %u, %p, %p, %u, %p, %p, %p, %p)\n", context, data->num_devices, @@ -147,6 +148,10 @@ int test_clLinkProgram(const struct clLinkProgram_st *data) test_icd_app_log("Value returned: %p\n", program); + test_icd_app_log("clReleaseProgram(%p)\n", program); + ret_val = clReleaseProgram(program); + test_icd_app_log("Value returned: %d\n", ret_val); + return 0; }