diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-02-12 15:13:33 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-02-18 22:14:23 +0100 |
commit | 9371b1cee88962ac632ed86968915d95a4625b2e (patch) | |
tree | 3b814c0d475c5132841174ad897ae202d590f336 | |
parent | 740340ca579ead75bd833a225e1bffe874d21769 (diff) |
Resolves: tdf#123298 resize before writing to vector
Change-Id: I8fc25d254781b31e4ffafcf4397a95d79e042cd8
Reviewed-on: https://gerrit.libreoffice.org/67738
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
(cherry picked from commit c9e1a5e8894dac6c5f1044dd0e98bc2d453fa995)
Reviewed-on: https://gerrit.libreoffice.org/67766
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index e23bfdfb0ef9..ed542157340b 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -1990,7 +1990,8 @@ inline void PDFWriterImpl::appendUnicodeTextStringEncrypt( const OUString& rInSt //prepare a unicode string, encrypt it enableStringEncryption( nInObjectNumber ); sal_uInt8 *pCopy = m_vEncryptionBuffer.data(); - sal_Int32 nChars = 2; + sal_Int32 nChars = 2 + (nLen * 2); + m_vEncryptionBuffer.resize(nChars); *pCopy++ = 0xFE; *pCopy++ = 0xFF; // we need to prepare a byte stream from the unicode string buffer @@ -1999,10 +2000,8 @@ inline void PDFWriterImpl::appendUnicodeTextStringEncrypt( const OUString& rInSt sal_Unicode aUnChar = pStr[i]; *pCopy++ = static_cast<sal_uInt8>( aUnChar >> 8 ); *pCopy++ = static_cast<sal_uInt8>( aUnChar & 255 ); - nChars += 2; } //encrypt in place - m_vEncryptionBuffer.resize(nChars); rtl_cipher_encodeARCFOUR( m_aCipher, m_vEncryptionBuffer.data(), nChars, m_vEncryptionBuffer.data(), nChars ); //now append, hexadecimal (appendHex), the encrypted result for(int i = 0; i < nChars; i++) |