Document assumptions that are being made to avoid NULL pointer dereferences #11132

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:document-non-nullptr-assumptions changing 3 files +5 −0
  1. practicalswift commented at 12:35 PM on August 25, 2017: contributor

    Document assumptions (via assert(…):s) that are being made avoid NULL pointer dereferences.

    Rationale:

    • Make it clear to human reviewers and non-human static analyzers that what might look like potential NULL pointer dereferences are written the way they are intentionally (these cases are currently flagged by various static analyzers).
  2. practicalswift force-pushed on Aug 25, 2017
  3. practicalswift force-pushed on Aug 25, 2017
  4. practicalswift renamed this:
    [wallet] Document assumptions that must be fulfilled to avoid NULL pointer dereferences
    Document assumptions that must be fulfilled to avoid NULL pointer dereferences
    on Aug 25, 2017
  5. practicalswift renamed this:
    Document assumptions that must be fulfilled to avoid NULL pointer dereferences
    Document assumptions that are being made to avoid NULL pointer dereferences
    on Aug 25, 2017
  6. practicalswift force-pushed on Aug 25, 2017
  7. in src/validation.cpp:1847 in 9291393380 outdated
    1843 | @@ -1843,6 +1844,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
    1844 |          if (!pblocktree->WriteTxIndex(vPos))
    1845 |              return AbortNode(state, "Failed to write transaction index");
    1846 |  
    1847 | +    assert(pindex->phashBlock && "pindex->phashBlock != nullptr assumed.");
    


    sipa commented at 4:18 PM on August 25, 2017:

    Repeating the condition in a message is not very useful.

  8. in src/validation.cpp:1707 in 9291393380 outdated
    1703 | @@ -1704,6 +1704,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
    1704 |      // before the first had been spent.  Since those coinbases are sufficiently buried its no longer possible to create further
    1705 |      // duplicate transactions descending from the known pairs either.
    1706 |      // If we're on the known chain at height greater than where BIP34 activated, we can save the db accesses needed for the BIP30 check.
    1707 | +    assert(pindex->pprev && "pindex->pprev != nullptr assumed.");
    


    sipa commented at 4:19 PM on August 25, 2017:

    Repeating the condition in a message is not very useful.


    meshcollider commented at 12:53 PM on August 26, 2017:

    Agree with @sipa, same thing as #11133

  9. laanwj added the label Docs and Output on Aug 26, 2017
  10. practicalswift force-pushed on Aug 28, 2017
  11. practicalswift commented at 7:25 AM on August 28, 2017: contributor

    @sipa Thanks for reviewing! Redundant comments removed. Looks good? :-)

  12. practicalswift force-pushed on Aug 28, 2017
  13. dcousens approved
  14. Document assumptions that are being made to avoid NULL pointer dereferences fdc329376c
  15. practicalswift force-pushed on Sep 6, 2017
  16. practicalswift commented at 8:46 AM on September 6, 2017: contributor

    Pushed an updated version. Now including cassert instead of assert.h.

  17. laanwj commented at 5:02 PM on September 20, 2017: member

    utACK fdc3293

  18. laanwj merged this on Sep 20, 2017
  19. laanwj closed this on Sep 20, 2017

  20. laanwj referenced this in commit 551d7bf604 on Sep 20, 2017
  21. PastaPastaPasta referenced this in commit f7b611f55c on Dec 22, 2019
  22. PastaPastaPasta referenced this in commit 728f37cdf7 on Jan 2, 2020
  23. PastaPastaPasta referenced this in commit e31a987e76 on Jan 4, 2020
  24. PastaPastaPasta referenced this in commit 03151d9329 on Jan 4, 2020
  25. PastaPastaPasta referenced this in commit bed575d10e on Jan 10, 2020
  26. PastaPastaPasta referenced this in commit 3004cee7db on Jan 10, 2020
  27. PastaPastaPasta referenced this in commit c8081ae192 on Jan 10, 2020
  28. PastaPastaPasta referenced this in commit 85fd876309 on Jan 12, 2020
  29. ckti referenced this in commit 32bfe201c4 on Mar 28, 2021
  30. MarcoFalke locked this on Sep 8, 2021

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