mempool: Document unsigned integer wraparounds in CTxMemPoolEntry::UpdateAncestorState(...) #14218

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:mempool-unsigned-integer-wraparound changing 1 files +5 −0
  1. practicalswift commented at 8:11 AM on September 14, 2018: contributor

    Document unsigned integer wraparounds in CTxMemPoolEntry::UpdateAncestorState(...).

  2. mempool: Document unsigned integer wraparounds in CTxMemPoolEntry::UpdateAncestorState(...) aaefdfc12d
  3. fanquake added the label Docs on Sep 14, 2018
  4. in src/txmempool.cpp:319 in aaefdfc12d
     313 | @@ -314,11 +314,16 @@ void CTxMemPoolEntry::UpdateDescendantState(int64_t modifySize, CAmount modifyFe
     314 |  
     315 |  void CTxMemPoolEntry::UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps)
     316 |  {
     317 | +    // An unsigned integer wraparound may take place here (modifySize is allowed to be negative).
     318 |      nSizeWithAncestors += modifySize;
     319 |      assert(int64_t(nSizeWithAncestors) > 0);
    


    MarcoFalke commented at 12:56 PM on September 14, 2018:

    I don't think this can wrap around in normal operation, since it is always first increased by some modifySize and only later reduced by the same modifySize.

    Also, note the assert, which would be hit if a wraparound occurs.

  5. practicalswift closed this on Sep 14, 2018

  6. practicalswift deleted the branch on Apr 10, 2021
  7. DrahtBot locked this on Aug 16, 2022
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me