Skip to content

Commit

Permalink
Fixing 'vector out of bounds' issue in base 32 and 64
Browse files Browse the repository at this point in the history
  • Loading branch information
ENikS committed Sep 18, 2014
1 parent 7fd8813 commit 018cec7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utilstrencodings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
string DecodeBase64(const string& str)
{
vector<unsigned char> vchRet = DecodeBase64(str.c_str());
return string((const char*)&vchRet[0], vchRet.size());
return (vchRet.size() == 0) ? string() : string((const char*)&vchRet[0], vchRet.size());
}

string EncodeBase32(const unsigned char* pch, size_t len)
Expand Down Expand Up @@ -411,7 +411,7 @@ vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
string DecodeBase32(const string& str)
{
vector<unsigned char> vchRet = DecodeBase32(str.c_str());
return string((const char*)&vchRet[0], vchRet.size());
return (vchRet.size() == 0) ? string() : string((const char*)&vchRet[0], vchRet.size());
}

bool ParseInt32(const std::string& str, int32_t *out)
Expand Down

0 comments on commit 018cec7

Please sign in to comment.