dashpay / dash

Dash - Reinventing Cryptocurrency
https://www.dash.org
MIT License
1.49k stars 1.2k forks source link

fix: move `g_txindex` initialization out of erroneous location and into constructor #6119

Closed kwvg closed 1 month ago

kwvg commented 1 month ago

Motivation

g_txindex should be initialized in TestChainSetup's constructor but when backporting bitcoin#19806 (dash#5236), portions of the constructor were split into TestChainSetup::mineBlocks(), g_txindex's init was left behind in the latter instead of the former.

This meant that every mineBlocks() call would re-create a TxIndex instance, which is not intended behaviour; and was recorded to cause heap-use-after-frees (comment, also the reason this PR was opened).

This PR aims to resolve that.

Additional Information

Checklist:

kwvg commented 1 month ago

Special thanks to @knst for spotting the heap-use-after-free