From 03168dd028d01f44d725691104a22476f8786121 Mon Sep 17 00:00:00 2001 From: ZXShady <153229951+ZXShady@users.noreply.github.com> Date: Sat, 28 Sep 2024 21:45:33 +0100 Subject: [PATCH] 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 --- src/CSFML/System/Time.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CSFML/System/Time.cpp b/src/CSFML/System/Time.cpp index 4b7b3161..00bd6144 100644 --- a/src/CSFML/System/Time.cpp +++ b/src/CSFML/System/Time.cpp @@ -63,7 +63,7 @@ sfTime sfSeconds(float amount) //////////////////////////////////////////////////////////// sfTime sfMilliseconds(int32_t amount) { - return {static_cast(amount * 1000)}; + return {int64_t{amount} * 1000}; }