Fix bug with accessing vchData[0] when vchData is empty.
Fix typo in CBase58Data::CompareTo
This commit is contained in:
parent
cb61b8dc4c
commit
03f8b54565
@ -173,6 +173,7 @@ protected:
|
|||||||
|
|
||||||
~CBase58Data()
|
~CBase58Data()
|
||||||
{
|
{
|
||||||
|
if (!vchData.empty())
|
||||||
memset(&vchData[0], 0, vchData.size());
|
memset(&vchData[0], 0, vchData.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,6 +181,7 @@ protected:
|
|||||||
{
|
{
|
||||||
nVersion = nVersionIn;
|
nVersion = nVersionIn;
|
||||||
vchData.resize(nSize);
|
vchData.resize(nSize);
|
||||||
|
if (!vchData.empty())
|
||||||
memcpy(&vchData[0], pdata, nSize);
|
memcpy(&vchData[0], pdata, nSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,6 +203,7 @@ public:
|
|||||||
}
|
}
|
||||||
nVersion = vchTemp[0];
|
nVersion = vchTemp[0];
|
||||||
vchData.resize(vchTemp.size() - 1);
|
vchData.resize(vchTemp.size() - 1);
|
||||||
|
if (!vchData.empty())
|
||||||
memcpy(&vchData[0], &vchTemp[1], vchData.size());
|
memcpy(&vchData[0], &vchTemp[1], vchData.size());
|
||||||
memset(&vchTemp[0], 0, vchTemp.size());
|
memset(&vchTemp[0], 0, vchTemp.size());
|
||||||
return true;
|
return true;
|
||||||
@ -221,7 +224,7 @@ public:
|
|||||||
int CompareTo(const CBase58Data& b58) const
|
int CompareTo(const CBase58Data& b58) const
|
||||||
{
|
{
|
||||||
if (nVersion < b58.nVersion) return -1;
|
if (nVersion < b58.nVersion) return -1;
|
||||||
if (nVersion < b58.nVersion) return 1;
|
if (nVersion > b58.nVersion) return 1;
|
||||||
if (vchData < b58.vchData) return -1;
|
if (vchData < b58.vchData) return -1;
|
||||||
if (vchData > b58.vchData) return 1;
|
if (vchData > b58.vchData) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user