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

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 17 12:55:00 UTC 2019


 vcl/source/gdi/gfxlink.cxx |   18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

New commits:
commit 0c8ac718247d374741c878b161d901c279d00bc8
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Mon Jun 17 14:01:42 2019 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Mon Jun 17 14:54:02 2019 +0200

    At least log errors in GfxLink::GetSwapInData
    
    I happened to get the below -fsanitize=invalid-null-argument failure just once
    during `--convert-to pdf xlsx/tdf114171-1.xlsx`, presumably as a consequence of
    an unknown error here.
    
    > tools/source/stream/stream.cxx:1687:24: runtime error: null pointer passed as argument 2, which is declared to never be null
    > /usr/include/string.h:43:28: note: nonnull attribute specified here
    >  #0 in SvMemoryStream::GetData(void*, unsigned long) at tools/source/stream/stream.cxx:1687:9
    >  #1 in SvStream::ReadBytes(void*, unsigned long) at tools/source/stream/stream.cxx:1232:18
    >  #2 in SvStream::readNumberWithoutSwap_(void*, int) at tools/source/stream/stream.cxx:149:9
    >  #3 in void SvStream::readNumberWithoutSwap<unsigned int>(unsigned int&) at include/tools/stream.hxx:412:7
    >  #4 in SvStream::ReadUInt32(unsigned int&) at tools/source/stream/stream.cxx:828:5
    >  #5 in GraphicDescriptor::ImpDetectGIF(SvStream&, bool) at vcl/source/filter/graphicfilter2.cxx:185:10
    >  #6 in GraphicDescriptor::Detect(bool) at vcl/source/filter/graphicfilter2.cxx:66:19
    >  #7 in ImpGraphic::ImplSetPrepared(bool, Size*) at vcl/source/gdi/impgraph.cxx:541:25
    >  #8 in GraphicFilter::ImportUnloadedGraphic(SvStream&, unsigned long, Size*) at vcl/source/filter/graphicfilter.cxx:1407:43
    >  #9 in (anonymous namespace)::GraphicProvider::queryGraphic(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at vcl/source/graphic/UnoGraphicProvider.cxx:410:44
    >  #10 in non-virtual thunk to (anonymous namespace)::GraphicProvider::queryGraphic(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) at vcl/source/graphic/UnoGraphicProvider.cxx
    >  #11 in oox::GraphicHelper::importGraphic(com::sun::star::uno::Reference<com::sun::star::io::XInputStream> const&, WmfExternal const*) const at oox/source/helper/graphichelper.cxx:275:39
    >  #12 in oox::GraphicHelper::importEmbeddedGraphic(rtl::OUString const&, WmfExternal const*) const at oox/source/helper/graphichelper.cxx:363:24
    >  #13 in  #33 in oox::xls::Shape::finalizeXShape(oox::core::XmlFilterBase&, com::sun::star::uno::Reference<com::sun::star::drawing::XShapes> const&) at sc/source/filter/oox/drawingfragment.cxx:112:30
    [...]
    
    Change-Id: I7fb38aad6b2147d650e3907d5734d8ade84353d8
    Reviewed-on: https://gerrit.libreoffice.org/74165
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/vcl/source/gdi/gfxlink.cxx b/vcl/source/gdi/gfxlink.cxx
index e92c06b4573a..e042a48e0aa4 100644
--- a/vcl/source/gdi/gfxlink.cxx
+++ b/vcl/source/gdi/gfxlink.cxx
@@ -272,10 +272,22 @@ std::shared_ptr<sal_uInt8> GfxLink::GetSwapInData() const
     SvFileStream aFileStream(mpSwapOutData->maURL, StreamMode::STD_READ);
     pData = o3tl::make_shared_array<sal_uInt8>(mnSwapInDataSize);
     aFileStream.ReadBytes(pData.get(), mnSwapInDataSize);
-    bool bError = (ERRCODE_NONE != aFileStream.GetError());
-    sal_uInt64 const nActReadSize = aFileStream.Tell();
-    if (nActReadSize != mnSwapInDataSize)
+    bool bError = false;
+    auto const e = aFileStream.GetError();
+    if (e != ERRCODE_NONE) {
+        SAL_WARN("vcl", "reading <" << mpSwapOutData->maURL << "> failed with " << e);
         bError = true;
+    }
+    if (!bError) {
+        sal_uInt64 const nActReadSize = aFileStream.Tell();
+        if (nActReadSize != mnSwapInDataSize) {
+            SAL_WARN(
+                "vcl",
+                "reading <" << mpSwapOutData->maURL << "> produced " << nActReadSize
+                    << " instead of " << mnSwapInDataSize << " bytes");
+            bError = true;
+        }
+    }
     if (bError)
         pData.reset();
     return pData;


More information about the Libreoffice-commits mailing list