Skip to content

Commit 0b12096

Browse files
committed
Fixed coverity issue in acl_mem.cpp: Dereference after null check
1 parent d35856a commit 0b12096

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/acl_mem.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,7 +2033,7 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueReadImageIntelFPGA(
20332033
return errcode_ret;
20342034
}
20352035
} else {
2036-
src_element_size = 0;
2036+
return CL_INVALID_MEM_OBJECT;
20372037
}
20382038

20392039
tmp_src_offset[0] = origin[0];
@@ -2773,13 +2773,17 @@ CL_API_ENTRY void *CL_API_CALL clEnqueueMapImageIntelFPGA(
27732773
image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_BUFFER) {
27742774
if (image_slice_pitch != NULL) {
27752775
*image_slice_pitch = 0;
2776+
} else {
2777+
BAIL_INFO(CL_INVALID_VALUE, command_queue->context,
2778+
"Invalid slice pitch provided");
27762779
}
27772780
} else if (image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_ARRAY) {
27782781
*image_slice_pitch = tmp_row_pitch;
27792782
} else {
27802783
*image_slice_pitch =
27812784
image->fields.image_objs.image_desc->image_height * tmp_row_pitch;
27822785
}
2786+
27832787
tmp_slice_pitch = *image_slice_pitch;
27842788
}
27852789

@@ -6820,12 +6824,12 @@ static void acl_dump_mem_internal(cl_mem mem) {
68206824
(mem->block_allocation->region->uses_host_system_malloc
68216825
? "is malloc"
68226826
: "not malloc"));
6827+
printf(" .begin %p\n",
6828+
mem->block_allocation->range.begin);
6829+
printf(" .end %p\n",
6830+
mem->block_allocation->range.next);
68236831
}
68246832
printf(" .mappings %d\n", mem->mapping_count);
6825-
printf(" .begin %p\n",
6826-
mem->block_allocation->range.begin);
6827-
printf(" .end %p\n",
6828-
mem->block_allocation->range.next);
68296833
acl_print_debug_msg(" .size %lu\n", mem->size);
68306834
printf(" .host_ptr %p\n",
68316835
mem->fields.buffer_objs.host_ptr);

0 commit comments

Comments
 (0)