// Copyright (c) 2009-2010 Satoshi Nakamoto
+// Copyright (c) 2011 The Bitcoin Developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
~CBase58Data()
{
- memset(&vchData[0], 0, vchData.size());
+ if (!vchData.empty())
+ memset(&vchData[0], 0, vchData.size());
}
void SetData(int nVersionIn, const void* pdata, size_t nSize)
{
nVersion = nVersionIn;
vchData.resize(nSize);
- memcpy(&vchData[0], pdata, nSize);
+ if (!vchData.empty())
+ memcpy(&vchData[0], pdata, nSize);
}
void SetData(int nVersionIn, const unsigned char *pbegin, const unsigned char *pend)
}
nVersion = vchTemp[0];
vchData.resize(vchTemp.size() - 1);
- memcpy(&vchData[0], &vchTemp[1], vchData.size());
+ if (!vchData.empty())
+ memcpy(&vchData[0], &vchTemp[1], vchData.size());
memset(&vchTemp[0], 0, vchTemp.size());
return true;
}
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 (vchData < b58.vchData) return -1;
if (vchData > b58.vchData) return 1;
return 0;
bool SetHash160(const uint160& hash160)
{
SetData(fTestNet ? 111 : 0, &hash160, 20);
+ return true;
}
bool SetPubKey(const std::vector<unsigned char>& vchPubKey)