From: Jeff Garzik Date: Tue, 22 May 2012 19:23:17 +0000 (-0400) Subject: Prevent crashes due to missing or corrupted blk????.dat records X-Git-Tag: v0.4.0-unstable~129^2~1^2^2~2^2^2 X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=a2de1ea2d5776289c247bbc18c1ed13e16a4169f;hp=b6862f7b74d0ea7442cf3b9eec7b9556ca47ce4b;p=novacoin.git Prevent crashes due to missing or corrupted blk????.dat records --- diff --git a/src/main.h b/src/main.h index b1c7885..44624f5 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))