Skip to content

Commit 6cd26f2

Browse files
authored
[SYCLomatic] Fix potential multiply overflow issue (#697)
Signed-off-by: chenwei.sun <[email protected]>
1 parent dbd0538 commit 6cd26f2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

clang/runtime/dpct-rt/include/util.hpp.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ inline void matrix_mem_copy(void *to_ptr, const void *from_ptr, int to_ld,
110110
}
111111

112112
if (to_ld == from_ld) {
113-
size_t cpoy_size = elem_size * ((cols - 1) * to_ld + rows);
113+
size_t cpoy_size = elem_size * ((cols - 1) * (size_t)to_ld + rows);
114114
if (async)
115115
detail::dpct_memcpy(queue, (void *)to_ptr, (void *)from_ptr,
116116
cpoy_size, direction);

clang/test/dpct/helper_files_ref/include/util.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ inline void matrix_mem_copy(void *to_ptr, const void *from_ptr, int to_ld,
5656
}
5757

5858
if (to_ld == from_ld) {
59-
size_t cpoy_size = elem_size * ((cols - 1) * to_ld + rows);
59+
size_t cpoy_size = elem_size * ((cols - 1) * (size_t)to_ld + rows);
6060
if (async)
6161
detail::dpct_memcpy(queue, (void *)to_ptr, (void *)from_ptr,
6262
cpoy_size, direction);

0 commit comments

Comments
 (0)