From 47e205487dfdebbb49fa09abf7c8ce7a13c396fc Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Mon, 12 Dec 2022 12:16:49 -0800 Subject: [PATCH] Fix potential integer overflow in test::hash --- test/objects/test.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/objects/test.hpp b/test/objects/test.hpp index 0bcf78e8..b1a253e5 100644 --- a/test/objects/test.hpp +++ b/test/objects/test.hpp @@ -230,18 +230,18 @@ namespace test { std::size_t operator()(int x) const { - int result; + unsigned result; switch (type_) { case 1: - result = x; + result = static_cast(x); break; case 2: - result = x * 7; + result = static_cast(x) * 7; break; default: - result = x * 256; + result = static_cast(x) * 256; } - return static_cast(result); + return result; } friend bool operator==(hash const& x1, hash const& x2)