From 96f6dc9fc50b1cc59e26d50940ebf46e1bdcc0ba Mon Sep 17 00:00:00 2001 From: practicalswift Date: Thu, 18 Oct 2018 11:17:05 +0200 Subject: [PATCH] Avoid triggering undefined behaviour in base_uint::bits() --- src/arith_uint256.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arith_uint256.cpp b/src/arith_uint256.cpp index 13fa176f8bf..791dad7a605 100644 --- a/src/arith_uint256.cpp +++ b/src/arith_uint256.cpp @@ -176,7 +176,7 @@ unsigned int base_uint::bits() const for (int pos = WIDTH - 1; pos >= 0; pos--) { if (pn[pos]) { for (int nbits = 31; nbits > 0; nbits--) { - if (pn[pos] & 1 << nbits) + if (pn[pos] & 1U << nbits) return 32 * pos + nbits + 1; } return 32 * pos + 1;