mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-25 05:03:36 +01:00
Cast to larger type before doing arithmetic to avoid signed integer overflow
https://godbolt.org/z/soTad4zEq this godbolt links shows that it is UB to multiply then cast if the amount is large enough
This commit is contained in:
1 parent
f297287951
commit
b626f65ee5
2 files changed
+4
-1
No files matched your search
@@ -28,4 +28,7 @@ TEST_CASE("[System] sfTime")
|
||||
CHECK(sfSeconds(10).microseconds == 10'000'000);
|
||||
CHECK(sfMilliseconds(10).microseconds == 10'000);
|
||||
CHECK(sfMicroseconds(10).microseconds == 10);
|
||||
|
||||
CHECK(sfMilliseconds(std::numeric_limits<int32_t>::max()).microseconds == 2'147'483'647'000);
|
||||
CHECK(sfMicroseconds(std::numeric_limits<int64_t>::max()).microseconds == std::numeric_limits<int64_t>::max());
|
||||
}
|
||||
Reference in new issue
Block a user