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

Caolán McNamara caolanm at redhat.com
Wed Jun 20 10:24:07 UTC 2018


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

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

    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>

diff --git a/include/vcl/ppdparser.hxx b/include/vcl/ppdparser.hxx
index 78f47417ae84..b0bddea9acb1 100644
--- a/include/vcl/ppdparser.hxx
+++ b/include/vcl/ppdparser.hxx
@@ -261,7 +261,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 edf377e7665e..8d3ae1cf9801 100644
--- a/vcl/unx/generic/printer/jobdata.cxx
+++ b/vcl/unx/generic/printer/jobdata.cxx
@@ -278,8 +278,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 e4b14c5c0b17..c333306bf0ef 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -1905,17 +1905,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 )
+    size_t nBytes = rBuffer.size() - 1;
+    size_t nRun = 0;
+    while (nBytes && rBuffer[nRun])
     {
-        OString aLine( pRun );
+        OString aLine(rBuffer.data() + nRun);
         sal_Int32 nPos = aLine.indexOf(':');
         if( nPos != -1 )
         {
@@ -1935,7 +1936,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