aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/mac/poly1305/poly1305.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/mac/poly1305/poly1305.cpp')
-rw-r--r--src/lib/mac/poly1305/poly1305.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/mac/poly1305/poly1305.cpp b/src/lib/mac/poly1305/poly1305.cpp
index 545a749fa..506150b0f 100644
--- a/src/lib/mac/poly1305/poly1305.cpp
+++ b/src/lib/mac/poly1305/poly1305.cpp
@@ -190,7 +190,11 @@ void Poly1305::final_result(byte out[])
if(m_buf_pos != 0)
{
m_buf[m_buf_pos] = 1;
- clear_mem(&m_buf[m_buf_pos+1], m_buf.size() - m_buf_pos - 1);
+ const auto len = m_buf.size() - m_buf_pos - 1;
+ if (len > 0)
+ {
+ clear_mem(&m_buf[m_buf_pos+1], len);
+ }
poly1305_blocks(m_poly, m_buf.data(), 1, true);
}