Bugfix: getwork/getmemorypool: NULL pindexPrev across CreateNewBlock, in case it fails #1245

pull luke-jr wants to merge 3 commits into bitcoin:master from luke-jr:bugfix_CNBerr changing 1 files +20 −2
  1. luke-jr commented at 5:12 PM on May 9, 2012: member

    Without this, the following bugs are possible:

    1. NULL pointer dereference
    • CreateNewBlock returns NULL (out of memory); pblock is left NULL and JSON error thrown
    • Next call sees pindexPrev/nTransactionsUpdatedLast/nStart up to date, so skips over making a new one
    • This next call then tries to update the time on the "current" pblock (NULL)
    1. Deleted object dereference
    • CreateNewBlock throws an exception (not sure if this is possible right now); pblock is left with a pointer to a deleted CBlock
    • Next call sees pindexPrev/nTransactionsUpdatedLast/nStart up to date, so skips over making a new one
    • This next call then tried to update the time on the 'current' pblock (which is deleted)
    • Consequences of this memory corruption are undefined!
  2. Bugfix: getwork: NULL pindexPrev across CreateNewBlock, in case it fails b354251f1a
  3. Merge branch 'bugfix_CNBerr_daggy' into bugfix_CNBerr
    Conflicts:
    	rpc.cpp
    5146599b01
  4. luke-jr referenced this in commit b3af7ba10d on May 9, 2012
  5. Bugfix: getmemorypool: NULL pindexPrev across CreateNewBlock, in case it fails 5d53f48acb
  6. luke-jr referenced this in commit 6f52cad0f6 on May 10, 2012
  7. luke-jr commented at 7:19 PM on May 19, 2012: member

    Eligius has been running this from block 179513 (56 blocks found) and EclipseMC from 180573 (11 blocks), totalling 67 valid blocks with no problems found.

  8. luke-jr referenced this in commit 3cd01fdf0e on May 27, 2012
  9. gavinandresen commented at 2:43 PM on June 27, 2012: contributor

    ACK

  10. gavinandresen merged this on Jul 26, 2012
  11. gavinandresen closed this on Jul 26, 2012

  12. suprnurd referenced this in commit 8d7866cf6b on Dec 5, 2017
  13. lateminer referenced this in commit be16d4b70a on Jan 22, 2019
  14. lateminer referenced this in commit 9cf807d800 on May 6, 2020
  15. lateminer referenced this in commit 805800164e on May 6, 2020
  16. DrahtBot 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-14 15:16 UTC

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