Skip to content

Commit c05d279

Browse files
committed
Fixed coverity in acl_program.cpp: Use after free (USE_AFTER_FREE)
1 parent 501821f commit c05d279

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/acl_program.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,14 +1819,16 @@ static cl_int l_build_from_source_in_dir(acl_device_program_info_t *dev_prog,
18191819
if (status == CL_SUCCESS && context->compiles_programs) {
18201820
for (unsigned i = 0; i < num_build_cmds; i++) {
18211821
struct acl_file_handle_t *cmdfp = acl_fopen(cmdfile[i], "wb");
1822+
if (debug_mode > 0) {
1823+
printf(" cmdfp %p\n", cmdfp);
1824+
}
18221825
size_t bytes_written = 0;
18231826
if (cmdfp) {
18241827
bytes_written = (size_t)acl_fprintf(cmdfp, "%s", cmd[i].c_str());
18251828
acl_fclose(cmdfp); // close in any case.
18261829
}
18271830
if (!cmdfp || (cmd[i].length() != bytes_written)) {
18281831
if (debug_mode > 0) {
1829-
printf(" cmdfp %p\n", cmdfp);
18301832
printf(" cmdlen %d bw %d\n", (int)cmd[i].length(),
18311833
(int)bytes_written);
18321834
}

src/acl_usm.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ CL_API_ENTRY void *CL_API_CALL clHostMemAllocINTEL(
112112
case CL_MEM_ALLOC_BUFFER_LOCATION_INTEL: {
113113
mem_id = (cl_uint) * (properties + 1);
114114
} break;
115-
default: {
116-
BAIL_INFO(CL_INVALID_PROPERTY, context, "Invalid properties");
117-
}
115+
default: { BAIL_INFO(CL_INVALID_PROPERTY, context, "Invalid properties"); }
118116
}
119117
properties += 2;
120118
}
@@ -265,9 +263,7 @@ clDeviceMemAllocINTEL(cl_context context, cl_device_id device,
265263
case CL_MEM_ALLOC_BUFFER_LOCATION_INTEL: {
266264
mem_id = (cl_uint) * (properties + 1);
267265
} break;
268-
default: {
269-
BAIL_INFO(CL_INVALID_DEVICE, context, "Invalid properties");
270-
}
266+
default: { BAIL_INFO(CL_INVALID_DEVICE, context, "Invalid properties"); }
271267
}
272268
properties += 2;
273269
}
@@ -419,9 +415,7 @@ clSharedMemAllocINTEL(cl_context context, cl_device_id device,
419415
}
420416
mem_id = (cl_uint) * (properties + 1);
421417
} break;
422-
default: {
423-
BAIL_INFO(CL_INVALID_PROPERTY, context, "Invalid properties");
424-
}
418+
default: { BAIL_INFO(CL_INVALID_PROPERTY, context, "Invalid properties"); }
425419
}
426420
properties += 2;
427421
}

0 commit comments

Comments
 (0)