Cleared UBsan warnings under GCC 5.1

pull/35/head
Jeffrey Walton 2015-07-17 07:13:23 -04:00
parent 3a08e02f71
commit 427e1cf028
1 changed files with 9 additions and 3 deletions

View File

@ -27,7 +27,9 @@ template <class T, class BASE> void IteratedHashBase<T, BASE>::Update(const byte
{ {
if (num+len >= blockSize) if (num+len >= blockSize)
{ {
if(data && input)
memcpy(data+num, input, blockSize-num); memcpy(data+num, input, blockSize-num);
HashBlock(dataBuf); HashBlock(dataBuf);
input += (blockSize-num); input += (blockSize-num);
len -= (blockSize-num); len -= (blockSize-num);
@ -36,7 +38,9 @@ template <class T, class BASE> void IteratedHashBase<T, BASE>::Update(const byte
} }
else else
{ {
if(data && input)
memcpy(data+num, input, len); memcpy(data+num, input, len);
return; return;
} }
} }
@ -59,7 +63,9 @@ template <class T, class BASE> void IteratedHashBase<T, BASE>::Update(const byte
else else
do do
{ // copy input first if it's not aligned correctly { // copy input first if it's not aligned correctly
if(data && input)
memcpy(data, input, blockSize); memcpy(data, input, blockSize);
HashBlock(dataBuf); HashBlock(dataBuf);
input+=blockSize; input+=blockSize;
len-=blockSize; len-=blockSize;