aboutsummaryrefslogtreecommitdiff
path: root/src/db.h
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@exmulti.com>2012-05-22 14:39:49 -0700
committerJeff Garzik <jgarzik@exmulti.com>2012-05-22 14:39:49 -0700
commit5d0f7c4f47e6b9aa382846dd9b4a034e724d461a (patch)
treece4b08cbe53dee3091698617fdcecb1665f7ccd0 /src/db.h
parentfa638ec8af92d6deaf17d3c09b03406808f19904 (diff)
parent8fe791e4e2db4b66f47d44d2ecaf734e2a36e5ed (diff)
Merge pull request #1381 from jgarzik/check-deser
Prevent crashes due to missing or corrupted database records
Diffstat (limited to 'src/db.h')
-rw-r--r--src/db.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/db.h b/src/db.h
index b8fc4db512..a67193b680 100644
--- a/src/db.h
+++ b/src/db.h
@@ -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());