diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2014-09-19 18:37:48 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2014-09-19 18:42:00 +0200 |
commit | 2fc6c67400e91846ca1c1c57011e57491013f9bd (patch) | |
tree | c067241cb3e98133d21017f5994c580a3d43e0d5 /src | |
parent | 7fd881367544fcc9e70130bf448a181794da26ab (diff) | |
parent | 018cec7c41e5fca9cfe80c618444a4d343fc44e2 (diff) |
Merge pull request #4944
018cec7 Fixing 'vector out of bounds' issue in base 32 and 64 (ENikS)
Diffstat (limited to 'src')
-rw-r--r-- | src/utilstrencodings.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index 6837e4e267..2cec3023b5 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -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) @@ -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) |