diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2017-10-02 21:03:05 +0300 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-10-04 15:27:25 +0000 |
commit | 4db6e37b18648dfe2c94b672276c7bf6554fd9d4 (patch) | |
tree | b69dae093c6370c4638af9281d5e5b54e889d6f3 /core/fpdfapi | |
parent | aafdc153a2b7609968b315ca6c6900717f6d6c36 (diff) | |
download | pdfium-4db6e37b18648dfe2c94b672276c7bf6554fd9d4.tar.xz |
Simplify CPDF_DataAvail::ParseIndirectObjectAt
Change-Id: I072df58730f323bb5d77d180382ea209cf47f930
Reviewed-on: https://pdfium-review.googlesource.com/13832
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.cpp | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index aaec4c7708..38e857f22f 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -634,30 +634,14 @@ std::unique_ptr<CPDF_Object> CPDF_DataAvail::ParseIndirectObjectAt( FX_FILESIZE pos, uint32_t objnum, CPDF_IndirectObjectHolder* pObjList) { - FX_FILESIZE SavedPos = m_syntaxParser.GetPos(); + const FX_FILESIZE SavedPos = m_syntaxParser.GetPos(); m_syntaxParser.SetPos(pos); - - bool bIsNumber; - ByteString word = m_syntaxParser.GetNextWord(&bIsNumber); - if (!bIsNumber) - return nullptr; - - uint32_t parser_objnum = FXSYS_atoui(word.c_str()); - if (objnum && parser_objnum != objnum) - return nullptr; - - word = m_syntaxParser.GetNextWord(&bIsNumber); - if (!bIsNumber) - return nullptr; - - if (m_syntaxParser.GetKeyword() != "obj") { - m_syntaxParser.SetPos(SavedPos); - return nullptr; - } - - std::unique_ptr<CPDF_Object> pObj = m_syntaxParser.GetObjectBody(pObjList); + std::unique_ptr<CPDF_Object> result = m_syntaxParser.GetIndirectObject( + pObjList, CPDF_SyntaxParser::ParseType::kLoose); m_syntaxParser.SetPos(SavedPos); - return pObj; + return (result && (!objnum || result->GetObjNum() == objnum)) + ? std::move(result) + : nullptr; } CPDF_DataAvail::DocLinearizationStatus CPDF_DataAvail::IsLinearizedPDF() { |