Skip to content

Commit

Permalink
fix #589: avoid resize -1
Browse files Browse the repository at this point in the history
  • Loading branch information
ithewei committed Jul 19, 2024
1 parent b350201 commit 703213d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion util/base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ HV_INLINE std::string Base64Decode(const char* str, unsigned int len = 0) {
int decoded_size = BASE64_DECODE_OUT_SIZE(len);
std::string decoded_buf(decoded_size + 1, 0);
decoded_size = hv_base64_decode(str, len, (unsigned char*)decoded_buf.data());
decoded_buf.resize(decoded_size);
if (decoded_size > 0) {
decoded_buf.resize(decoded_size);
} else {
decoded_buf.clear();
}
return decoded_buf;
}

Expand Down

0 comments on commit 703213d

Please sign in to comment.