Mercurial > hg > bitcoin
changeset 2811:6eafb872571b draft
Prevent crashes due to missing or corrupted blk????.dat records
In LoadExternalBlockFile(), errors are already caught... silently.
Add a warning message, even though we do not abort the program due to
load error.
author | Jeff Garzik <jgarzik@exmulti.com> |
---|---|
date | Tue, 22 May 2012 15:23:17 -0400 |
parents | a2f7bc9841e0 |
children | 20aca1dafc3b |
files | src/main.h |
diffstat | 1 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.h +++ b/src/main.h @@ -594,7 +594,13 @@ // 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) @@ -976,7 +982,12 @@ 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))