diff options
| author | Pieter Wuille <[email protected]> | 2011-07-18 06:38:54 -0700 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2011-07-18 06:38:54 -0700 |
| commit | ca40e581ebcdc85dba15c1e873f5e5aedda45b77 (patch) | |
| tree | 7e37fb19ab0b2c01024d6824103aa4d383147691 /src | |
| parent | split off CBase58Data from CBitcoinAddress (diff) | |
| parent | Fix bug with accessing vchData[0] when vchData is empty. (diff) | |
| download | discoin-ca40e581ebcdc85dba15c1e873f5e5aedda45b77.tar.xz discoin-ca40e581ebcdc85dba15c1e873f5e5aedda45b77.zip | |
Merge pull request #1 from AbrahamJewowich/cbitcoinaddress
Cbitcoinaddress
Diffstat (limited to 'src')
| -rw-r--r-- | src/base58.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/base58.h b/src/base58.h index 985b0447c..266412c86 100644 --- a/src/base58.h +++ b/src/base58.h @@ -173,14 +173,16 @@ protected: ~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) @@ -201,7 +203,8 @@ public: } 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; } @@ -221,7 +224,7 @@ public: 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; |