From 42c4afd969c90be4aea0378080f64159cd881ef1 Mon Sep 17 00:00:00 2001 From: "Yang, Hao Xiang" Date: Fri, 9 Dec 2022 10:39:16 -0800 Subject: [PATCH] Fixed coverity in acl_program.cpp: Use after free (USE_AFTER_FREE) --- src/acl_program.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/acl_program.cpp b/src/acl_program.cpp index fb5f03dd..922e3a6f 100644 --- a/src/acl_program.cpp +++ b/src/acl_program.cpp @@ -1821,6 +1821,7 @@ static cl_int l_build_from_source_in_dir(acl_device_program_info_t *dev_prog, if (status == CL_SUCCESS && context->compiles_programs) { for (unsigned i = 0; i < num_build_cmds; i++) { struct acl_file_handle_t *cmdfp = acl_fopen(cmdfile[i], "wb"); + auto cmdfp_addrs = &cmdfp; size_t bytes_written = 0; if (cmdfp) { bytes_written = (size_t)acl_fprintf(cmdfp, "%s", cmd[i].c_str()); @@ -1828,7 +1829,7 @@ static cl_int l_build_from_source_in_dir(acl_device_program_info_t *dev_prog, } if (!cmdfp || (cmd[i].length() != bytes_written)) { if (debug_mode > 0) { - printf(" cmdfp %p\n", cmdfp); + printf(" cmdfp %p\n", (void *)*cmdfp_addrs); printf(" cmdlen %d bw %d\n", (int)cmd[i].length(), (int)bytes_written); }