Skip to content

Commit

Permalink
Merge bitcoin/bitcoin#31431: util: use explicit cast in MultiIntBitSe…
Browse files Browse the repository at this point in the history
…t::Fill()

edb41e4 util: use explicit cast in MultiIntBitSet::Fill() (Vasil Dimov)

Pull request description:

  The current code does not have a bug, but is implicitly casting -1 to 65535 and the sanitizer has no way to know whether we intend that or not.

  ```
  FUZZ=bitset src/test/fuzz/fuzz /tmp/fuz

  error: implicit conversion from type 'int' of value -1 (32-bit, signed)
  to type 'value_type' (aka 'unsigned short') changed the value to 65535
  (16-bit, unsigned)

  Base64: Qv7bX/8=
  ```

  https://api.cirrus-ci.com/v1/task/5685829642747904/logs/ci.log

ACKs for top commit:
  sipa:
    ACK edb41e4
  maflcko:
    lgtm ACK edb41e4
  Empact:
    ACK edb41e4
  tdb3:
    code review ACK edb41e4

Tree-SHA512: a53835d654d9a7246ec0dab30fa5fbc08155dadb40d9bee3297060aa90816e0ce3d3e92dbdcd7af9474446d842d03f2781b7645a68ffef7fb5fc32ee02545112
  • Loading branch information
fanquake committed Dec 6, 2024
2 parents 2eccb8b + edb41e4 commit 5b283fa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/util/bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class MultiIntBitSet
if (count) {
unsigned i = 0;
while (count > LIMB_BITS) {
ret.m_val[i++] = ~I{0};
ret.m_val[i++] = I(~I{0});
count -= LIMB_BITS;
}
ret.m_val[i] = I(~I{0}) >> (LIMB_BITS - count);
Expand Down

0 comments on commit 5b283fa

Please sign in to comment.