aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@bitpay.com>2013-05-30 09:13:44 -0700
committerJeff Garzik <jgarzik@bitpay.com>2013-05-30 09:13:44 -0700
commit87ec1929cf74bf13fa008c70cdf4ac3765efade0 (patch)
treefc33465dd6d48d795b54ab6a48da96b68eb14d87
parentd3977156618ae9bb448aa76f579bf57f96c375ac (diff)
parent98ab2b5a265e4794d6a9d22212d992bfd1f9c1f1 (diff)
Merge pull request #2705 from robbak/crash_zero_size_peers.dat
Don't attempt to resize vector to negative size.
-rw-r--r--src/db.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/db.cpp b/src/db.cpp
index 3133d99bf8..fd4c67d552 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -541,6 +541,8 @@ bool CAddrDB::Read(CAddrMan& addr)
// use file size to size memory buffer
int fileSize = GetFilesize(filein);
int dataSize = fileSize - sizeof(uint256);
+ //Don't try to resize to a negative number if file is small
+ if ( dataSize < 0 ) dataSize = 0;
vector<unsigned char> vchData;
vchData.resize(dataSize);
uint256 hashIn;