[Libreoffice-commits] core.git: vcl/unx

Caolán McNamara caolanm at redhat.com
Mon Mar 12 17:09:41 UTC 2018


 vcl/unx/generic/printer/jobdata.cxx |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

New commits:
commit f879f7125f12f9a7fde0175b4f1fcc3c1686e642
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 12 11:35:37 2018 +0000

    forcepoint #25 ensure null termination
    
    Change-Id: I37f4787fb5772e959c45280d9650adcc15591033
    Reviewed-on: https://gerrit.libreoffice.org/51128
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/generic/printer/jobdata.cxx b/vcl/unx/generic/printer/jobdata.cxx
index 1206a7b5efca..edf377e7665e 100644
--- a/vcl/unx/generic/printer/jobdata.cxx
+++ b/vcl/unx/generic/printer/jobdata.cxx
@@ -273,11 +273,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;
+                    }
                 }
             }
         }


More information about the Libreoffice-commits mailing list