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 /tools | |
parent | 35ba68fd471d7d2f50183a1ffb7348b1b069616d (diff) |
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>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/stream/stream.cxx | 6 |
1 files changed, 6 insertions, 0 deletions
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 |