Skip to content

Commit 361d952

Browse files
committed
Fix subscript[0] in base58.cpp
1 parent 6896dbf commit 361d952

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/base58.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)
110110

111111
std::string EncodeBase58(const std::vector<unsigned char>& vch)
112112
{
113-
return EncodeBase58(&vch[0], &vch[0] + vch.size());
113+
return EncodeBase58(vch.data(), vch.data() + vch.size());
114114
}
115115

116116
bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet)
@@ -160,7 +160,7 @@ void CBase58Data::SetData(const std::vector<unsigned char>& vchVersionIn, const
160160
vchVersion = vchVersionIn;
161161
vchData.resize(nSize);
162162
if (!vchData.empty())
163-
memcpy(&vchData[0], pdata, nSize);
163+
memcpy(vchData.data(), pdata, nSize);
164164
}
165165

166166
void CBase58Data::SetData(const std::vector<unsigned char>& vchVersionIn, const unsigned char* pbegin, const unsigned char* pend)
@@ -180,8 +180,8 @@ bool CBase58Data::SetString(const char* psz, unsigned int nVersionBytes)
180180
vchVersion.assign(vchTemp.begin(), vchTemp.begin() + nVersionBytes);
181181
vchData.resize(vchTemp.size() - nVersionBytes);
182182
if (!vchData.empty())
183-
memcpy(&vchData[0], &vchTemp[nVersionBytes], vchData.size());
184-
memory_cleanse(&vchTemp[0], vchTemp.size());
183+
memcpy(vchData.data(), vchTemp.data() + nVersionBytes, vchData.size());
184+
memory_cleanse(vchTemp.data(), vchTemp.size());
185185
return true;
186186
}
187187

@@ -262,7 +262,7 @@ CTxDestination CBitcoinAddress::Get() const
262262
if (!IsValid())
263263
return CNoDestination();
264264
uint160 id;
265-
memcpy(&id, &vchData[0], 20);
265+
memcpy(&id, vchData.data(), 20);
266266
if (vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
267267
return CKeyID(id);
268268
else if (vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS))
@@ -276,7 +276,7 @@ bool CBitcoinAddress::GetKeyID(CKeyID& keyID) const
276276
if (!IsValid() || vchVersion != Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
277277
return false;
278278
uint160 id;
279-
memcpy(&id, &vchData[0], 20);
279+
memcpy(&id, vchData.data(), 20);
280280
keyID = CKeyID(id);
281281
return true;
282282
}

src/base58.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ template<typename K, int Size, CChainParams::Base58Type Type> class CBitcoinExtK
148148
K ret;
149149
if (vchData.size() == Size) {
150150
// If base58 encoded data does not hold an ext key, return a !IsValid() key
151-
ret.Decode(&vchData[0]);
151+
ret.Decode(vchData.data());
152152
}
153153
return ret;
154154
}

0 commit comments

Comments
 (0)