aboutsummaryrefslogtreecommitdiff
path: root/src/main.h
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@exmulti.com>2012-05-22 15:23:17 -0400
committerLuke Dashjr <luke-jr+git@utopios.org>2012-05-22 22:50:02 +0000
commita2de1ea2d5776289c247bbc18c1ed13e16a4169f (patch)
tree5c5cd829bc985832eaa9976080f6d3180a3fde61 /src/main.h
parentb6862f7b74d0ea7442cf3b9eec7b9556ca47ce4b (diff)
downloadbitcoin-a2de1ea2d5776289c247bbc18c1ed13e16a4169f.tar.xz
Prevent crashes due to missing or corrupted blk????.dat records
Diffstat (limited to 'src/main.h')
-rw-r--r--src/main.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main.h b/src/main.h
index b1c78854a1..44624f5cf7 100644
--- a/src/main.h
+++ b/src/main.h
@@ -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))