mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
Avoid triggering undefined behaviour in base_uint<BITS>::bits()
This commit is contained in:
@@ -176,7 +176,7 @@ unsigned int base_uint<BITS>::bits() const
|
|||||||
for (int pos = WIDTH - 1; pos >= 0; pos--) {
|
for (int pos = WIDTH - 1; pos >= 0; pos--) {
|
||||||
if (pn[pos]) {
|
if (pn[pos]) {
|
||||||
for (int nbits = 31; nbits > 0; nbits--) {
|
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 + nbits + 1;
|
||||||
}
|
}
|
||||||
return 32 * pos + 1;
|
return 32 * pos + 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user