From 9fc6c355ffcd77ddd856224333be82bcc86dd26e Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Mon, 7 Aug 2017 15:17:42 +0000 Subject: [PATCH] Safer remainder calculation --- lut.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lut.h b/lut.h index d576c09..1f8e06c 100644 --- a/lut.h +++ b/lut.h @@ -130,7 +130,8 @@ constexpr std::pair Lut3d::FindChannelRoot(const ui // points - 1 is the last point index. Since we're going to fidn the cube // around this point by adding to the root, we need to be at least 1 less // than that. - return std::make_pair(std::min(points - 2, value / BlockSize(points)), value % BlockSize(points));; + uint32_t index = std::min(points - 2, value / BlockSize(points)); + return std::make_pair(index, value - (index * BlockSize(points))); } template