Skip to content

Commit

Permalink
Fixed coverity in acl_program.cpp: Use after free (USE_AFTER_FREE)
Browse files Browse the repository at this point in the history
  • Loading branch information
haoxian2 committed Dec 9, 2022
1 parent 55a4ac7 commit 42c4afd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/acl_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1821,14 +1821,15 @@ 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());
acl_fclose(cmdfp); // close in any case.
}
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);
}
Expand Down

0 comments on commit 42c4afd

Please # to comment.