diff options
author | Jeff Garzik <jgarzik@exmulti.com> | 2012-05-22 15:12:52 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2012-05-22 15:12:52 -0400 |
commit | f94b64c2f3a1994a21c4d99a1806d4f9611f810c (patch) | |
tree | 71565f3f86e1cedc0118242cd6d0899cecb32718 /src/db.h | |
parent | d1edab602a3ee729b308378d9d456f01e6933cfb (diff) |
Prevent crashes due to missing or corrupted database records
Any problems seen during deserialization will throw an uncaught
exception, crashing the entire bitcoin process. Properly return an
error instead, so that we may at least log the error and gracefully
shutdown other portions of the app.
Diffstat (limited to 'src/db.h')
-rw-r--r-- | src/db.h | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -72,8 +72,13 @@ protected: return false; // Unserialize value - CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK, CLIENT_VERSION); - ssValue >> value; + try { + CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK, CLIENT_VERSION); + ssValue >> value; + } + catch (std::exception &e) { + return false; + } // Clear and free memory memset(datValue.get_data(), 0, datValue.get_size()); |