[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - package/source

Caolán McNamara caolanm at redhat.com
Wed Jan 3 16:00:28 UTC 2018


 package/source/zipapi/ZipFile.cxx |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 6a40c4e0ddf606f2fac776764eede2fb5ccde354
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 27 18:38:42 2017 +0000

    ofz#4806 Infinite loop
    
    Change-Id: I89a24fa3ce4034ef207233b96c5e26a7b7787444
    Reviewed-on: https://gerrit.libreoffice.org/47101
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 61f7ea1dacc1..de4c1a364acd 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -539,6 +539,7 @@ public:
         const sal_Int32 nBufSize = 8192;
 
         sal_Int32 nRemaining = xSrcStream->available();
+        sal_Int32 nRead = 0;
         maBytes.reserve(nRemaining);
         uno::Sequence<sal_Int8> aBuf(nBufSize);
 
@@ -552,10 +553,17 @@ public:
         };
 
         while (nRemaining > nBufSize)
-            nRemaining -= readAndCopy(nBufSize);
+        {
+            const auto nBytes = readAndCopy(nBufSize);
+            if (!nBytes)
+                break;
+            nRead += nBytes;
+            nRemaining -= nBytes;
+        }
 
         if (nRemaining)
-            readAndCopy(nRemaining);
+            nRead += readAndCopy(nRemaining);
+        maBytes.resize(nRead);
     }
 
     virtual sal_Int32 SAL_CALL readBytes( uno::Sequence<sal_Int8>& rData, sal_Int32 nBytesToRead ) override


More information about the Libreoffice-commits mailing list