diff options
author | Jeff Garzik <jgarzik@exmulti.com> | 2012-05-22 15:23:17 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2012-05-22 15:23:17 -0400 |
commit | 8fe791e4e2db4b66f47d44d2ecaf734e2a36e5ed (patch) | |
tree | 7cfbbcc8c0dd418f852e4de9618d3d241163d5b3 /src/main.h | |
parent | f94b64c2f3a1994a21c4d99a1806d4f9611f810c (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.
Diffstat (limited to 'src/main.h')
-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 ac5ba254ce..c0fe63a32a 100644 --- a/src/main.h +++ b/src/main.h @@ -593,7 +593,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) @@ -969,7 +975,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)) |