Skip to content

Commit 47d10af

Browse files
Avoid int overflow during multiplication (NVIDIA#3981)
This issue was reported by Coverity in nvCOMP Fixes NVBug 5064232
1 parent eb178cb commit 47d10af

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cub/cub/grid/grid_even_share.cuh

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ public:
135135
int avg_tiles_per_block = total_tiles / grid_size;
136136
// leftover grains go to big blocks:
137137
this->big_shares = total_tiles - (avg_tiles_per_block * grid_size);
138-
this->normal_share_items = avg_tiles_per_block * tile_items;
139-
this->normal_base_offset = big_shares * tile_items;
138+
this->normal_share_items = static_cast<OffsetT>(avg_tiles_per_block) * tile_items;
139+
this->normal_base_offset = static_cast<OffsetT>(big_shares) * tile_items;
140140
this->big_share_items = normal_share_items + tile_items;
141141
}
142142

0 commit comments

Comments
 (0)