From 0bdbde2c21afeb858ebd6e2106c13b35b55b7ca6 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 20 May 2017 02:12:43 -0400 Subject: Clear coverity finding FORWARD_NULL (CID 147865) --- cryptlib.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'cryptlib.cpp') diff --git a/cryptlib.cpp b/cryptlib.cpp index 24eb0209..9f1e749c 100644 --- a/cryptlib.cpp +++ b/cryptlib.cpp @@ -171,18 +171,18 @@ size_t BlockTransformation::AdvancedProcessBlocks(const byte *inBlocks, const by outIncrement = 0-outIncrement; } + // Coverity finding CID 147865. In practice, if BT_XorInput, then xorBlocks is non-NULL. + bool xorFlag = (flags & BT_XorInput) && (xorBlocks != NULLPTR); while (length >= blockSize) { - if (flags & BT_XorInput) + if (xorFlag) { - // Coverity finding. However, xorBlocks is never NULL if BT_XorInput. - CRYPTOPP_ASSERT(xorBlocks); xorbuf(outBlocks, xorBlocks, inBlocks, blockSize); + xorBlocks += xorIncrement; ProcessBlock(outBlocks); } else { - // xorBlocks can be NULL. See, for example, ECB_OneWay::ProcessData. ProcessAndXorBlock(inBlocks, xorBlocks, outBlocks); } @@ -190,7 +190,6 @@ size_t BlockTransformation::AdvancedProcessBlocks(const byte *inBlocks, const by const_cast(inBlocks)[blockSize-1]++; inBlocks += inIncrement; outBlocks += outIncrement; - xorBlocks += xorIncrement; length -= blockSize; } -- cgit v1.2.1