From 6ac1e46a1fb01f01705b67dd553d5ba317b1dc3e Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 18 Nov 2015 15:32:28 -0500 Subject: Cleared issues 11,12,13 (Clang integrated assembler), 58 (RC rollup), 66 (Coverity rollup) --- sha3.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'sha3.cpp') diff --git a/sha3.cpp b/sha3.cpp index 7db82c19..9ab24ec8 100644 --- a/sha3.cpp +++ b/sha3.cpp @@ -251,17 +251,23 @@ static void KeccakF1600(word64 *state) void SHA3::Update(const byte *input, size_t length) { + assert((input && length) || !(input || length)); + if (!length) + return; + size_t spaceLeft; while (length >= (spaceLeft = r() - m_counter)) { - xorbuf(m_state.BytePtr() + m_counter, input, spaceLeft); + if (spaceLeft) + xorbuf(m_state.BytePtr() + m_counter, input, spaceLeft); KeccakF1600(m_state); input += spaceLeft; length -= spaceLeft; m_counter = 0; } - xorbuf(m_state.BytePtr() + m_counter, input, length); + if (length) + xorbuf(m_state.BytePtr() + m_counter, input, length); m_counter += (unsigned int)length; } -- cgit v1.2.1