aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/codec/base64
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/codec/base64')
-rw-r--r--src/lib/codec/base64/base64.cpp13
-rw-r--r--src/lib/codec/base64/base64.h2
2 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/codec/base64/base64.cpp b/src/lib/codec/base64/base64.cpp
index aaf04d9d2..1b1767aa1 100644
--- a/src/lib/codec/base64/base64.cpp
+++ b/src/lib/codec/base64/base64.cpp
@@ -84,9 +84,14 @@ std::string base64_encode(const byte input[],
std::string output(output_length, 0);
size_t consumed = 0;
- size_t produced = base64_encode(&output[0],
- input, input_length,
- consumed, true);
+ size_t produced = 0;
+
+ if (output_length > 0)
+ {
+ produced = base64_encode(&output.front(),
+ input, input_length,
+ consumed, true);
+ }
BOTAN_ASSERT_EQUAL(consumed, input_length, "Consumed the entire input");
BOTAN_ASSERT_EQUAL(produced, output.size(), "Produced expected size");
@@ -232,7 +237,7 @@ secure_vector<byte> base64_decode(const char input[],
: (round_up<size_t>(input_length, 4) * 3) / 4;
secure_vector<byte> bin(output_length);
- size_t written = base64_decode(&bin[0],
+ size_t written = base64_decode(bin.data(),
input,
input_length,
ignore_ws);
diff --git a/src/lib/codec/base64/base64.h b/src/lib/codec/base64/base64.h
index ab7bb5a1c..92c4dc627 100644
--- a/src/lib/codec/base64/base64.h
+++ b/src/lib/codec/base64/base64.h
@@ -49,7 +49,7 @@ std::string BOTAN_DLL base64_encode(const byte input[],
template<typename Alloc>
std::string base64_encode(const std::vector<byte, Alloc>& input)
{
- return base64_encode(&input[0], input.size());
+ return base64_encode(input.data(), input.size());
}
/**