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 authored and zibaiwan committed Jan 19, 2023
1 parent f510b0a commit 3e1c5ea
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/acl_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1819,14 +1819,16 @@ 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");
if (debug_mode > 0) {
printf(" cmdfp %p\n", 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(" cmdlen %d bw %d\n", (int)cmd[i].length(),
(int)bytes_written);
}
Expand Down

0 comments on commit 3e1c5ea

Please # to comment.