[Libreoffice-commits] core.git: filter/source include/tools sw/source tools/source

Caolán McNamara caolanm at redhat.com
Tue Jul 11 12:48:09 UTC 2017


 filter/source/graphicfilter/ieps/ieps.cxx |    9 ---------
 filter/source/graphicfilter/iras/iras.cxx |    9 ---------
 filter/source/msfilter/msdffimp.cxx       |    9 ---------
 include/tools/stream.hxx                  |    2 ++
 sw/source/filter/ww8/ww8scan.cxx          |    6 ------
 sw/source/filter/ww8/ww8scan.hxx          |    3 ---
 tools/source/stream/stream.cxx            |    6 ++++++
 7 files changed, 8 insertions(+), 36 deletions(-)

New commits:
commit 093744321759b4e3d73d767459272addfb22cf04
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jul 11 08:52:20 2017 +0100

    ofz#2538: avoid oom
    
    and merge together checkSeeks
    
    Change-Id: I341a09404280fb8d4acfbe2abaed47e2830af55f
    Reviewed-on: https://gerrit.libreoffice.org/39800
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx
index 845b5ea854ff..d752a836ee3c 100644
--- a/filter/source/graphicfilter/ieps/ieps.cxx
+++ b/filter/source/graphicfilter/ieps/ieps.cxx
@@ -401,15 +401,6 @@ static bool RenderAsBMP(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &r
         return RenderAsBMPThroughConvert(pBuf, nBytesRead, rGraphic);
 }
 
-namespace
-{
-    bool checkSeek(SvStream &rSt, sal_uInt32 nOffset)
-    {
-        const sal_uInt64 nMaxSeek(rSt.Tell() + rSt.remainingSize());
-        return (nOffset <= nMaxSeek && rSt.Seek(nOffset) == nOffset);
-    }
-}
-
 // this method adds a replacement action containing the original wmf or tiff replacement,
 // so the original eps can be written when storing to ODF.
 void CreateMtfReplacementAction( GDIMetaFile& rMtf, SvStream& rStrm, sal_uInt32 nOrigPos, sal_uInt32 nPSSize,
diff --git a/filter/source/graphicfilter/iras/iras.cxx b/filter/source/graphicfilter/iras/iras.cxx
index 0f6dac97be75..4c878be321f7 100644
--- a/filter/source/graphicfilter/iras/iras.cxx
+++ b/filter/source/graphicfilter/iras/iras.cxx
@@ -78,15 +78,6 @@ RASReader::RASReader(SvStream &rRAS)
 {
 }
 
-namespace
-{
-    bool checkSeek(SvStream &rSt, sal_uInt32 nOffset)
-    {
-        const sal_uInt64 nMaxSeek(rSt.Tell() + rSt.remainingSize());
-        return (nOffset <= nMaxSeek && rSt.Seek(nOffset) == nOffset);
-    }
-}
-
 bool RASReader::ReadRAS(Graphic & rGraphic)
 {
     sal_uInt32 nMagicNumber;
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index a450efb226b9..a3afce6202cd 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -221,15 +221,6 @@ DffPropertyReader::DffPropertyReader( const SvxMSDffManager& rMan )
     InitializePropSet( DFF_msofbtOPT );
 }
 
-namespace
-{
-    bool checkSeek(SvStream &rSt, sal_uInt32 nOffset)
-    {
-        const sal_uInt64 nMaxSeek(rSt.Tell() + rSt.remainingSize());
-        return (nOffset <= nMaxSeek && rSt.Seek(nOffset) == nOffset);
-    }
-}
-
 void DffPropertyReader::SetDefaultPropSet( SvStream& rStCtrl, sal_uInt32 nOffsDgg ) const
 {
     const_cast<DffPropertyReader*>(this)->pDefaultPropSet.reset();
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index b8f30625d822..b3dece37e83b 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -579,6 +579,8 @@ inline std::size_t write_uInt16_lenPrefixed_uInt8s_FromOUString(SvStream& rStrm,
     return write_uInt16_lenPrefixed_uInt8s_FromOString(rStrm, OUStringToOString(rStr, eEnc));
 }
 
+TOOLS_DLLPUBLIC bool checkSeek(SvStream &rSt, sal_uInt64 nOffset) SAL_WARN_UNUSED_RESULT;
+
 // FileStream
 
 class TOOLS_DLLPUBLIC SvFileStream : public SvStream
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 6e75c781bdde..0512ab977b98 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -8066,12 +8066,6 @@ SEPr::SEPr() :
     memset(rgdxaColumnWidthSpacing, 0, sizeof(rgdxaColumnWidthSpacing));
 }
 
-bool checkSeek(SvStream &rSt, sal_uInt32 nOffset)
-{
-    const sal_uInt64 nMaxSeek(rSt.Tell() + rSt.remainingSize());
-    return (nOffset <= nMaxSeek && rSt.Seek(nOffset) == nOffset);
-}
-
 bool checkRead(SvStream &rSt, void *pDest, sal_uInt32 nLength)
 {
     return (rSt.ReadBytes(pDest, nLength) == static_cast<std::size_t>(nLength));
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index 22ae96e0d85a..91c50f83b510 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -1859,9 +1859,6 @@ void SwapQuotesInField(OUString &rFormat);
 Word2CHPX ReadWord2Chpx(SvStream &rSt, std::size_t nOffset, sal_uInt8 nSize);
 std::vector<sal_uInt8> ChpxToSprms(const Word2CHPX &rChpx);
 
-bool checkSeek(SvStream &rSt, sal_uInt32 nOffset)
-    SAL_WARN_UNUSED_RESULT;
-
 bool checkRead(SvStream &rSt, void *pDest, sal_uInt32 nLength)
     SAL_WARN_UNUSED_RESULT;
 
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index cdfac8273470..8c8d294f1164 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1392,6 +1392,12 @@ sal_uInt64 SvStream::Seek(sal_uInt64 const nFilePos)
     return m_nBufFilePos + m_nBufActualPos;
 }
 
+bool checkSeek(SvStream &rSt, sal_uInt64 nOffset)
+{
+    const sal_uInt64 nMaxSeek(rSt.Tell() + rSt.remainingSize());
+    return (nOffset <= nMaxSeek && rSt.Seek(nOffset) == nOffset);
+}
+
 //STREAM_SEEK_TO_END in the some of the Seek backends is special cased to be
 //efficient, in others e.g. SotStorageStream it's really horribly slow, and in
 //those this should be overridden


More information about the Libreoffice-commits mailing list