Fix string out-of-bounds access

This commit is contained in:
Marián Konček 2024-11-05 15:20:58 +01:00 committed by Frédéric Mangano
parent a54bac8f55
commit 76afc0efd5

View File

@ -56,7 +56,7 @@ std::u8string ot::encode_base64(ot::byte_string_view src)
ot::byte_string ot::decode_base64(std::u8string_view src)
{
// Remove the padding and rely on the string length instead.
while (src.back() == u8'=')
while (!src.empty() && src.back() == u8'=')
src.remove_suffix(1);
size_t olen = src.size() / 4 * 3; // Whole blocks;