diff options
author | Jeff Garzik <jgarzik@exmulti.com> | 2012-05-22 15:23:17 -0400 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2012-06-19 15:38:45 -0400 |
commit | 57ca021e7ee2fb80b4c06605b2126d54135ba7ff (patch) | |
tree | 7378748046f3eea7455afbe8a656e1a9a4a85fc9 | |
parent | 4bd6299efdeb8438d0a58aa7c1083a6faeeaa71b (diff) |
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.
-rw-r--r-- | src/main.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main.h b/src/main.h index 262e77e806..96187d3c5f 100644 --- a/src/main.h +++ b/src/main.h @@ -594,7 +594,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) @@ -976,7 +982,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)) |