From 33bba6028ce98fc811235f829f88d7d6778409de Mon Sep 17 00:00:00 2001 From: MerryMage Date: Wed, 24 Jan 2018 16:15:17 +0000 Subject: [PATCH] bit_util: bug: Infinite loop in HighestSetBit --- src/common/bit_util.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/bit_util.h b/src/common/bit_util.h index fb93fbea..3168578d 100644 --- a/src/common/bit_util.h +++ b/src/common/bit_util.h @@ -101,6 +101,9 @@ inline int HighestSetBit(T value) { template inline size_t LowestSetBit(T value) { auto x = static_cast>(value); + if (x == 0) + return BitSize(); + size_t result = 0; while ((x & 1) == 0) { x >>= 1;