diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2017-09-01 18:52:30 +0300 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-05 15:07:57 +0000 |
commit | d2608a87173f00cb80830d56b52eeb588055ba3a (patch) | |
tree | 7cb97990ac1407f25c3f6415b346c7c049b649bc /core/fpdfapi/parser/cpdf_syntax_parser.cpp | |
parent | 088ca03f25fe1f6d75c0ff3b71e0ad3d018a5e0c (diff) | |
download | pdfium-d2608a87173f00cb80830d56b52eeb588055ba3a.tar.xz |
Move Parsing of indirect object logic into CPDF_SyntaxParser.
Change-Id: I5473d6db3e6fc247d52a83b34424958dc20387f4
Reviewed-on: https://pdfium-review.googlesource.com/12150
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_syntax_parser.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index e3a23cf462..73932494c0 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -529,6 +529,49 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectForStrict( return result; } +std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetIndirectObject( + CPDF_IndirectObjectHolder* pObjList, + uint32_t objnum, + bool bDecrypt, + ParseType parse_type) { + const CPDF_ReadValidator::Session read_session(GetValidator().Get()); + const FX_FILESIZE saved_pos = GetPos(); + bool is_number = false; + CFX_ByteString word = GetNextWord(&is_number); + if (!is_number || word.IsEmpty()) { + SetPos(saved_pos); + return nullptr; + } + + uint32_t parser_objnum = FXSYS_atoui(word.c_str()); + if (objnum && parser_objnum != objnum) { + SetPos(saved_pos); + return nullptr; + } + + word = GetNextWord(&is_number); + if (!is_number || word.IsEmpty()) { + SetPos(saved_pos); + return nullptr; + } + + const uint32_t parser_gennum = FXSYS_atoui(word.c_str()); + if (GetKeyword() != "obj") { + SetPos(saved_pos); + return nullptr; + } + + std::unique_ptr<CPDF_Object> pObj = + GetObjectInternal(pObjList, objnum, parser_gennum, bDecrypt, parse_type); + if (pObj) { + if (!objnum) + pObj->m_ObjNum = parser_objnum; + pObj->m_GenNum = parser_gennum; + } + + return GetValidator()->has_read_problems() ? nullptr : std::move(pObj); +} + unsigned int CPDF_SyntaxParser::ReadEOLMarkers(FX_FILESIZE pos) { unsigned char byte1 = 0; unsigned char byte2 = 0; |