vcl/source/filter/graphicfilter.cxx |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 52dfeeb636d2502ec639346736c420b636f1140f
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon May 9 18:21:54 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon May 9 22:30:46 2022 +0200

    crashtesting: use of negative return indication failure as length
    
    a problem since...
    
        commit e9c50fbbc3b07ef927d133da9cf2395c55611e0f
        Date:   Sat Apr 2 15:49:32 2022 +0300
    
            tdf#103954: Z compressed graphic formats support for EMF/WMF
    
    Change-Id: Ia994587bf411a2cda3df38cb209313171b78ee9a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134091
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index 9651861655b6..44534025337a 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1175,10 +1175,14 @@ ErrCode GraphicFilter::readWMF_EMF(SvStream & rStream, 
Graphic & rGraphic, GfxLi
     {
         ZCodec aCodec;
         aCodec.BeginCompression(ZCODEC_DEFAULT_COMPRESSION, /*gzLib*/true);
-        nStreamLength = aCodec.Decompress(rStream, aMemStream);
+        auto nDecompressLength = aCodec.Decompress(rStream, aMemStream);
         aCodec.EndCompression();
         aMemStream.Seek(STREAM_SEEK_TO_BEGIN);
-        aNewStream = &aMemStream;
+        if (nDecompressLength >= 0)
+        {
+            nStreamLength = nDecompressLength;
+            aNewStream = &aMemStream;
+        }
     }
     VectorGraphicDataArray aNewData(nStreamLength);
     aNewStream->ReadBytes(aNewData.getArray(), nStreamLength);

Reply via email to