From 0af9e1c4577bc9e1813fb875177ad0902bc951eb Mon Sep 17 00:00:00 2001 From: mjpt777 Date: Wed, 14 Nov 2018 08:43:46 +0000 Subject: [PATCH] [c++] Cast after modulo operation to avoid overflow. Issue #579. --- .../src/main/cpp/concurrent/logbuffer/LogBufferDescriptor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aeron-client/src/main/cpp/concurrent/logbuffer/LogBufferDescriptor.h b/aeron-client/src/main/cpp/concurrent/logbuffer/LogBufferDescriptor.h index 0831f794e7..5b84f813b6 100644 --- a/aeron-client/src/main/cpp/concurrent/logbuffer/LogBufferDescriptor.h +++ b/aeron-client/src/main/cpp/concurrent/logbuffer/LogBufferDescriptor.h @@ -270,7 +270,7 @@ inline static int indexByTermCount(std::int64_t termCount) AERON_NOEXCEPT inline static int indexByPosition(std::int64_t position, std::int32_t positionBitsToShift) AERON_NOEXCEPT { - return (int)((std::uint64_t)position >> positionBitsToShift) % PARTITION_COUNT; + return static_cast(((std::uint64_t)position >> positionBitsToShift) % PARTITION_COUNT); } inline static std::int64_t computePosition(