You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
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
@@ -194,9 +194,9 @@ struct GDScriptUtilityFunctionsDefinitions {
|
||||
// Calculate how many.
|
||||
int count = 0;
|
||||
if (incr > 0) {
|
||||
count = ((to - from - 1) / incr) + 1;
|
||||
count = Math::division_round_up(to - from, incr);
|
||||
} else {
|
||||
count = ((from - to - 1) / -incr) + 1;
|
||||
count = Math::division_round_up(from - to, -incr);
|
||||
}
|
||||
|
||||
Error err = arr.resize(count);
|
||||
|
||||
Reference in New Issue
Block a user