From 781e63ba7cb669cfe70278956f6264b3488da453 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 10 Jan 2017 22:05:53 -0500 Subject: [PATCH] =?UTF-8?q?Fix=20RoundUpToMultipleOf=20(Issue=20360)=20Tha?= =?UTF-8?q?nks=20to=20Boldizs=C3=A1r=20Lipka?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- misc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc.h b/misc.h index aa7cd447..6b8a2fa2 100644 --- a/misc.h +++ b/misc.h @@ -904,7 +904,7 @@ inline T1 RoundDownToMultipleOf(const T1 &n, const T2 &m) template inline T1 RoundUpToMultipleOf(const T1 &n, const T2 &m) { - if (n > (SIZE_MAX/sizeof(T1))-m-1) + if (std::numeric_limits::max() - m + 1 < n) throw InvalidArgument("RoundUpToMultipleOf: integer overflow"); return RoundDownToMultipleOf(T1(n+m-1), m); }