summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-03-12 11:35:37 +0000
committerAndras Timar <andras.timar@collabora.com>2018-04-07 17:43:43 +0200
commit7edcaf4ebeb759bd5a5a1a9c8da727cd70dc1839 (patch)
tree7be8a10844cffe238aac0c01ab5f8c240c5f8d54
parent488d164793409041a370d815aca381e05ffbddb2 (diff)
forcepoint #25 ensure null termination
Change-Id: I37f4787fb5772e959c45280d9650adcc15591033 Reviewed-on: https://gerrit.libreoffice.org/51130 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 5a6a1e932f2efe9646d927f20b2cca9ca12a3a70)
-rw-r--r--vcl/unx/generic/printer/jobdata.cxx14
1 files changed, 9 insertions, 5 deletions
diff --git a/vcl/unx/generic/printer/jobdata.cxx b/vcl/unx/generic/printer/jobdata.cxx
index b9359429fd8a..89673ba05b34 100644
--- a/vcl/unx/generic/printer/jobdata.cxx
+++ b/vcl/unx/generic/printer/jobdata.cxx
@@ -274,11 +274,15 @@ bool JobData::constructFromStreamBuffer( const void* pData, sal_uInt32 bytes, Jo
if( rJobData.m_pParser )
{
rJobData.m_aContext.setParser( rJobData.m_pParser );
- const sal_uInt64 nBytes = bytes - aStream.Tell();
- std::unique_ptr<char[]> pRemain(new char[bytes - aStream.Tell()]);
- aStream.ReadBytes( pRemain.get(), nBytes );
- rJobData.m_aContext.rebuildFromStreamBuffer( pRemain.get(), nBytes );
- bContext = true;
+ sal_uInt64 nBytes = bytes - aStream.Tell();
+ std::vector<char> aRemain(nBytes+1);
+ nBytes = aStream.ReadBytes(aRemain.data(), nBytes);
+ if (nBytes)
+ {
+ aRemain[nBytes] = 0;
+ rJobData.m_aContext.rebuildFromStreamBuffer(aRemain.data(), nBytes);
+ bContext = true;
+ }
}
}
}