Prevent crashes due to missing or corrupted blk????.dat records

This commit is contained in:
Jeff Garzik
2012-05-22 15:23:17 -04:00
committed by Luke Dashjr
parent b6862f7b74
commit a2de1ea2d5

View File

@@ -601,7 +601,13 @@ public:
// Read transaction
if (fseek(filein, pos.nTxPos, SEEK_SET) != 0)
return error("CTransaction::ReadFromDisk() : fseek failed");
filein >> *this;
try {
filein >> *this;
}
catch (std::exception &e) {
return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__);
}
// Return file pointer
if (pfileRet)
@@ -993,7 +999,12 @@ public:
filein.nType |= SER_BLOCKHEADERONLY;
// Read block
filein >> *this;
try {
filein >> *this;
}
catch (std::exception &e) {
return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__);
}
// Check the header
if (!CheckProofOfWork(GetHash(), nBits))