CID
1232604 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
overflow_before_widen: Potentially overflowing expression
(unsigned int)abs(this->merge_threshold) * 16U * this->split_multiplier
with type unsigned int (32 bits, unsigned) is evaluated using 32-bit
arithmetic before being used in a context which expects an expression of
type uint64_t const (64 bits, unsigned). To avoid overflow, cast either
operand to uint64_t const before performing the multiplication.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
// Calculate the number of leaf folders (which actually store files)
// need to be created
- const uint64_t objs_per_folder = (unsigned)(abs(merge_threshold)) * 16 * split_multiplier;
+ const uint64_t objs_per_folder = (uint64_t)(abs(merge_threshold)) * (uint64_t)split_multiplier * 16;
uint64_t leavies = expected_num_objs / objs_per_folder ;
// No need to split
if (leavies == 0 || expected_num_objs == objs_per_folder)