diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-01-16 15:58:44 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-01-16 22:19:23 +0100 |
commit | 575aac6ddbed1eba9c2941e0b31ac5ae08eed58d (patch) | |
tree | a22ced609997b66d67722b7f9fd2f43b3ba57e27 /lotuswordpro/source/filter/lwp9reader.cxx | |
parent | 18e9fc8bad056fb7c20ed9a2689928f3c8735020 (diff) |
ofz#5420 Out-of-memory
Change-Id: I22166a14a03e5e803f8f032034e05a2da501379f
Reviewed-on: https://gerrit.libreoffice.org/48008
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'lotuswordpro/source/filter/lwp9reader.cxx')
-rw-r--r-- | lotuswordpro/source/filter/lwp9reader.cxx | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lotuswordpro/source/filter/lwp9reader.cxx b/lotuswordpro/source/filter/lwp9reader.cxx index 60a2911a7ca9..e278fc8e1a88 100644 --- a/lotuswordpro/source/filter/lwp9reader.cxx +++ b/lotuswordpro/source/filter/lwp9reader.cxx @@ -75,20 +75,22 @@ Lwp9Reader::Lwp9Reader (LwpSvStream* pInputStream, IXFStream* pStream) /** * @descr The entrance of Word Pro 9 import filter. **/ -void Lwp9Reader::Read() +bool Lwp9Reader::Read() { + bool bRet = true; LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance(m_pDocStream); try { m_pObjMgr = pGlobal->GetLwpObjFactory(); - ReadFileHeader(); //Does not support Word Pro 96 and previous versions - if(LwpFileHeader::m_nFileRevision>=0x000B) + if (ReadFileHeader() && LwpFileHeader::m_nFileRevision>=0x000B) { ReadIndex(); - ParseDocument(); + bRet = ParseDocument(); } + else + bRet = false; } catch(...) { @@ -96,14 +98,16 @@ void Lwp9Reader::Read() throw; } LwpGlobalMgr::DeleteInstance(); + return bRet; } /** * @descr Read the LWP7 object. */ -void Lwp9Reader::ReadFileHeader() +bool Lwp9Reader::ReadFileHeader() { - m_pDocStream->Seek(LwpSvStream::LWP_STREAM_BASE); + if (!m_pDocStream->CheckSeek(LwpSvStream::LWP_STREAM_BASE)) + return false; //Remember to initialize the LwpFileHeader::m_nFileRevision first. LwpFileHeader::m_nFileRevision = 0; @@ -112,8 +116,7 @@ void Lwp9Reader::ReadFileHeader() objHdr.Read(*m_pDocStream); sal_Int64 pos = m_pDocStream->Tell(); m_LwpFileHdr.Read(m_pDocStream); - m_pDocStream->Seek(pos+objHdr.GetSize()); - + return m_pDocStream->CheckSeek(pos + objHdr.GetSize()); } /** @@ -131,7 +134,7 @@ void Lwp9Reader::ReadIndex() /** * @descr Parse all document content */ -void Lwp9Reader::ParseDocument() +bool Lwp9Reader::ParseDocument() { WriteDocHeader(); @@ -139,7 +142,7 @@ void Lwp9Reader::ParseDocument() LwpDocument* doc = dynamic_cast<LwpDocument*> ( m_LwpFileHdr.GetDocID().obj().get() ); if (!doc) - return; + return false; //Parse Doc Data LwpDocData *pDocData = dynamic_cast<LwpDocData*>(doc->GetDocData().obj().get()); @@ -165,6 +168,7 @@ void Lwp9Reader::ParseDocument() m_pStream->EndElement("office:body"); WriteDocEnd(); + return true; } /** |