mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-10 14:58:05 +00:00
Merge pull request #2705 from robbak/crash_zero_size_peers.dat
Don't attempt to resize vector to negative size.
This commit is contained in:
commit
87ec1929cf
@ -541,6 +541,8 @@ bool CAddrDB::Read(CAddrMan& addr)
|
|||||||
// use file size to size memory buffer
|
// use file size to size memory buffer
|
||||||
int fileSize = GetFilesize(filein);
|
int fileSize = GetFilesize(filein);
|
||||||
int dataSize = fileSize - sizeof(uint256);
|
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;
|
vector<unsigned char> vchData;
|
||||||
vchData.resize(dataSize);
|
vchData.resize(dataSize);
|
||||||
uint256 hashIn;
|
uint256 hashIn;
|
||||||
|
Loading…
Reference in New Issue
Block a user