From be1eedf808c2c2520079f134114d6707ae5117b4 Mon Sep 17 00:00:00 2001 From: Eli Fidler Date: Tue, 31 May 2016 12:22:21 -0400 Subject: [PATCH] avoid signed-integer overflow, which is undefined behavior UBSAN gave for test/unittest/itoatest.cpp:87: runtime error: signed integer overflow: 4611686018427387904 * 2 cannot be represented in type 'long' --- test/unittest/itoatest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/unittest/itoatest.cpp b/test/unittest/itoatest.cpp index 79db1c7..b752a6a 100644 --- a/test/unittest/itoatest.cpp +++ b/test/unittest/itoatest.cpp @@ -84,6 +84,8 @@ static void Verify(void(*f)(T, char*), char* (*g)(T, char*)) { VerifyValue(Traits::Negate(i + 1), f, g); } last = i; + if (i > static_cast(std::numeric_limits::max() / static_cast(power))) + break; i *= power; } while (last < i); }