From 54ec0d09949c45a5880a71f43b6a946b7f01ca9a Mon Sep 17 00:00:00 2001 From: Charles <18726788+csharpee@users.noreply.github.com> Date: Sun, 29 Mar 2020 03:01:46 -0400 Subject: [PATCH] updated undefined behavior in accordance with zcash remedy rex4539 #4056 --- src/arith_uint256.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/arith_uint256.cpp b/src/arith_uint256.cpp index e9c0dd056..d7a5c0afe 100644 --- a/src/arith_uint256.cpp +++ b/src/arith_uint256.cpp @@ -193,9 +193,10 @@ unsigned int base_uint::bits() const { for (int pos = WIDTH - 1; pos >= 0; pos--) { if (pn[pos]) { - for (int bits = 31; bits > 0; bits--) { - if (pn[pos] & 1 << bits) + for (size_t bits = 31; bits > 0; bits--) { + if (pn[pos] & (1U << bits)) { return 32 * pos + bits + 1; + } } return 32 * pos + 1; }