Browse Source

Partial: Sanitize assert usage and refuse to compile with NDEBUG.

There were quite a few places where assert() was used with side effects,
 making operation with NDEBUG non-functional.  This commit fixes all the
 cases I know about, but also adds an  #error on NDEBUG because the code
 is untested without assertions and may still have vulnerabilities if
 used without assert.

Conflicts:
	src/key.cpp
	src/main.cpp
	src/wallet.cpp

Rebased-from: 2e0c4da3fb1ce78dca1b3db723cf095a94f2f371 0.8.x
0.8
Gregory Maxwell 11 years ago committed by Warren Togami
parent
commit
4e0048e454
  1. 8
      src/main.cpp

8
src/main.cpp

@ -18,6 +18,10 @@ @@ -18,6 +18,10 @@
using namespace std;
using namespace boost;
#if defined(NDEBUG)
# error "Litecoin cannot be compiled without assertions."
#endif
//
// Global state
//
@ -1343,12 +1347,14 @@ unsigned int CTransaction::GetP2SHSigOpCount(CCoinsViewCache& inputs) const @@ -1343,12 +1347,14 @@ unsigned int CTransaction::GetP2SHSigOpCount(CCoinsViewCache& inputs) const
void CTransaction::UpdateCoins(CValidationState &state, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight, const uint256 &txhash) const
{
bool ret;
// mark inputs spent
if (!IsCoinBase()) {
BOOST_FOREACH(const CTxIn &txin, vin) {
CCoins &coins = inputs.GetCoins(txin.prevout.hash);
CTxInUndo undo;
assert(coins.Spend(txin.prevout, undo));
ret = coins.Spend(txin.prevout, undo);
assert(ret);
txundo.vprevout.push_back(undo);
}
}

Loading…
Cancel
Save