[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - include/vcl vcl/unx

Caolán McNamara caolanm at redhat.com
Mon Jul 2 11:04:53 UTC 2018


 include/vcl/ppdparser.hxx             |    2 +-
 vcl/unx/generic/printer/jobdata.cxx   |    3 ++-
 vcl/unx/generic/printer/ppdparser.cxx |   12 ++++++------
 3 files changed, 9 insertions(+), 8 deletions(-)

New commits:
commit 0cefb4f0552a9d1ec3afd64e695596480a1c9757
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jun 19 21:43:43 2018 +0100

    forcepoint#50 fix end detection
    
    rBuffer.size() of 26, nBytes of 25, rBuffer[25] is the first zero
    so aLine.getLength() of 25, nBytes reduced by aLine.getLength()+1 and
    nRun increased by same, so nBytes wraps and nRun is 26.
    
    contains...
    
    forcepoint: rework to explore loop
    
    Change-Id: I14f6a3269fc3347a9976d899519e74f58d5975c8
    Reviewed-on: https://gerrit.libreoffice.org/56125
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 6e5e83025c948b699bb65839ef810a45a98ba014)
    
    Change-Id: Ia9f4789e081e6b77a21321f37d71cabfc7c84550
    Reviewed-on: https://gerrit.libreoffice.org/56481
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>

diff --git a/include/vcl/ppdparser.hxx b/include/vcl/ppdparser.hxx
index a3a04b86fdff..2cac587cd1c0 100644
--- a/include/vcl/ppdparser.hxx
+++ b/include/vcl/ppdparser.hxx
@@ -269,7 +269,7 @@ public:
 
     // for printer setup
     char*   getStreamableBuffer( sal_uLong& rBytes ) const;
-    void    rebuildFromStreamBuffer( char* pBuffer, sal_uLong nBytes );
+    void    rebuildFromStreamBuffer(const std::vector<char> &rBuffer);
 
     // convenience
     int getRenderResolution() const;
diff --git a/vcl/unx/generic/printer/jobdata.cxx b/vcl/unx/generic/printer/jobdata.cxx
index 92f9204b51e2..43e33bc22d0d 100644
--- a/vcl/unx/generic/printer/jobdata.cxx
+++ b/vcl/unx/generic/printer/jobdata.cxx
@@ -279,8 +279,9 @@ bool JobData::constructFromStreamBuffer( const void* pData, sal_uInt32 bytes, Jo
                     nBytes = aStream.ReadBytes(aRemain.data(), nBytes);
                     if (nBytes)
                     {
+                        aRemain.resize(nBytes+1);
                         aRemain[nBytes] = 0;
-                        rJobData.m_aContext.rebuildFromStreamBuffer(aRemain.data(), nBytes);
+                        rJobData.m_aContext.rebuildFromStreamBuffer(aRemain);
                         bContext = true;
                     }
                 }
diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx
index b81359c8fea5..65a1b1cf30e3 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -1926,17 +1926,18 @@ char* PPDContext::getStreamableBuffer( sal_uLong& rBytes ) const
     return pBuffer;
 }
 
-void PPDContext::rebuildFromStreamBuffer( char* pBuffer, sal_uLong nBytes )
+void PPDContext::rebuildFromStreamBuffer(const std::vector<char> &rBuffer)
 {
     if( ! m_pParser )
         return;
 
     m_aCurrentValues.clear();
 
-    char* pRun = pBuffer;
-    while( nBytes && *pRun )
+    const size_t nBytes = rBuffer.size() - 1;
+    size_t nRun = 0;
+    while (nRun < nBytes && rBuffer[nRun])
     {
-        OString aLine( pRun );
+        OString aLine(rBuffer.data() + nRun);
         sal_Int32 nPos = aLine.indexOf(':');
         if( nPos != -1 )
         {
@@ -1955,8 +1956,7 @@ void PPDContext::rebuildFromStreamBuffer( char* pBuffer, sal_uLong nBytes )
                     << " }");
             }
         }
-        nBytes -= aLine.getLength()+1;
-        pRun += aLine.getLength()+1;
+        nRun += aLine.getLength()+1;
     }
 }
 


More information about the Libreoffice-commits mailing list