summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/pdfwriter_impl.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-02-12 15:13:33 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-02-12 17:34:30 +0100
commitaa31976c2e4399a86bc6f70f140972d9ccef6fc0 (patch)
treea2dbcd1fd7562c798654b36aa04da6fcaec97751 /vcl/source/gdi/pdfwriter_impl.cxx
parent20203f1bf9733f7a1212952920f7973f8fef1abe (diff)
Resolves: tdf#123298 resize before writing to vector
Change-Id: I8fc25d254781b31e4ffafcf4397a95d79e042cd8 Reviewed-on: https://gerrit.libreoffice.org/67736 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/gdi/pdfwriter_impl.cxx')
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx5
1 files changed, 2 insertions, 3 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index fdfc4cdabade..ada2cd648646 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -1983,7 +1983,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
@@ -1992,10 +1993,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++)