Fix potential integer underflow in rounded up divisions
A new `Math::division_round_up()` function was added, allowing for easy and correct computation of integer divisions when the result needs to be rounded up. Fixes #80358. Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
This commit is contained in:
committed by
Rémi Verschelde
parent
13a0d6e9b2
commit
8747c67d9e
@ -39,7 +39,7 @@ void BitMap::create(const Size2i &p_size) {
|
||||
|
||||
ERR_FAIL_COND(static_cast<int64_t>(p_size.width) * static_cast<int64_t>(p_size.height) > INT32_MAX);
|
||||
|
||||
Error err = bitmask.resize((((p_size.width * p_size.height) - 1) / 8) + 1);
|
||||
Error err = bitmask.resize(Math::division_round_up(p_size.width * p_size.height, 8));
|
||||
ERR_FAIL_COND(err != OK);
|
||||
|
||||
width = p_size.width;
|
||||
|
||||
Reference in New Issue
Block a user