diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-07-11 08:52:20 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-07-11 14:47:38 +0200 |
commit | 093744321759b4e3d73d767459272addfb22cf04 (patch) | |
tree | d75fe6272a335869c2862340b4d57705a73fb398 | |
parent | EditEngine: Added expwarp for unit tests (diff) | |
download | core-093744321759b4e3d73d767459272addfb22cf04.tar.gz core-093744321759b4e3d73d767459272addfb22cf04.zip |
ofz#2538: avoid oom
and merge together checkSeeks
Change-Id: I341a09404280fb8d4acfbe2abaed47e2830af55f
Reviewed-on: https://gerrit.libreoffice.org/39800
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | filter/source/graphicfilter/ieps/ieps.cxx | 9 | ||||
-rw-r--r-- | filter/source/graphicfilter/iras/iras.cxx | 9 | ||||
-rw-r--r-- | filter/source/msfilter/msdffimp.cxx | 9 | ||||
-rw-r--r-- | include/tools/stream.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.hxx | 3 | ||||
-rw-r--r-- | tools/source/stream/stream.cxx | 6 |
7 files changed, 8 insertions, 36 deletions
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 |