tdf#163486: PVS: Expression is always true

Since
commit 47a173edb6
Author: Noel Grandin <noelgrandin@gmail.com>
Date:   Sat Sep 15 18:36:08 2018 +0200

    use std::vector in PDFWriterImpl for encryption buffer

V547 	Expression 'buffOK' is always true.

Change-Id: I66b0f4de18cfca398da0b4091d980b259f5e9dfe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176916
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli
2024-11-21 12:15:34 +01:00
parent 7ebcea990c
commit d22d862ce6

View File

@@ -1661,16 +1661,14 @@ bool PDFWriterImpl::writeBufferBytes( const void* pBuffer, sal_uInt64 nBytes )
}
else
{
bool buffOK = true;
if (m_aPDFEncryptor.m_bEncryptThisStream)
{
/* implement the encryption part of the PDF spec encryption algorithm 3.1 */
m_vEncryptionBuffer.resize(nBytes);
if (buffOK)
rtl_cipher_encodeARCFOUR(m_aPDFEncryptor.m_aCipher, pBuffer, static_cast<sal_Size>(nBytes), m_vEncryptionBuffer.data(), static_cast<sal_Size>(nBytes));
rtl_cipher_encodeARCFOUR(m_aPDFEncryptor.m_aCipher, pBuffer, static_cast<sal_Size>(nBytes), m_vEncryptionBuffer.data(), static_cast<sal_Size>(nBytes));
}
const void* pWriteBuffer = (m_aPDFEncryptor.m_bEncryptThisStream && buffOK) ? m_vEncryptionBuffer.data() : pBuffer;
const void* pWriteBuffer = m_aPDFEncryptor.m_bEncryptThisStream ? m_vEncryptionBuffer.data() : pBuffer;
m_DocDigest.update(static_cast<unsigned char const*>(pWriteBuffer), static_cast<sal_uInt32>(nBytes));
if (m_aFile.write(pWriteBuffer, nBytes, nWritten) != osl::File::E_None)