mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Fix occurences of c_str() used with size() to data()
Using `data()` better communicates the intent here. Also, depending on how `c_str()` is implemented, this fixes undefined behavior: The part of the string after the first NULL character might have undefined contents.
This commit is contained in:
@@ -138,7 +138,7 @@ std::string EncodeBase64(const unsigned char* pch, size_t len)
|
||||
|
||||
std::string EncodeBase64(const std::string& str)
|
||||
{
|
||||
return EncodeBase64((const unsigned char*)str.c_str(), str.size());
|
||||
return EncodeBase64((const unsigned char*)str.data(), str.size());
|
||||
}
|
||||
|
||||
std::vector<unsigned char> DecodeBase64(const char* p, bool* pf_invalid)
|
||||
@@ -207,7 +207,7 @@ std::string EncodeBase32(const unsigned char* pch, size_t len)
|
||||
|
||||
std::string EncodeBase32(const std::string& str)
|
||||
{
|
||||
return EncodeBase32((const unsigned char*)str.c_str(), str.size());
|
||||
return EncodeBase32((const unsigned char*)str.data(), str.size());
|
||||
}
|
||||
|
||||
std::vector<unsigned char> DecodeBase32(const char* p, bool* pf_invalid)
|
||||
|
||||
Reference in New Issue
Block a user