summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-27 21:14:22 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-27 21:14:22 +0000
commita2c2a9d2a1e718e08bb90f92a2f24f4cb990189f (patch)
tree79b96a806474543b292a3b6b3df9d8fcc74b8a50 /core/fpdfapi/parser
parent3ab8fa91422e8ce6874f9a89a61cb043858ad8b5 (diff)
downloadpdfium-a2c2a9d2a1e718e08bb90f92a2f24f4cb990189f.tar.xz
Add fxcrt::AutoRestorer<T>::AbandonRestoration().chromium/3475
Kinda like reaching a commit point, makes going forward more useful. Change-Id: I7695b6e627d4cd8ed2bccb667d0cabd7f42c7b1c Reviewed-on: https://pdfium-review.googlesource.com/35970 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
index 3cce446aae..0910a39e2a 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
@@ -359,7 +359,7 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectBody(
std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectBodyInternal(
CPDF_IndirectObjectHolder* pObjList,
ParseType parse_type) {
- AutoRestorer<int> restorer(&s_CurrentRecursionDepth);
+ AutoRestorer<int> depth_restorer(&s_CurrentRecursionDepth);
if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth)
return nullptr;
@@ -370,19 +370,21 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectBodyInternal(
return nullptr;
if (bIsNumber) {
- FX_FILESIZE SavedPos = m_Pos;
+ AutoRestorer<FX_FILESIZE> pos_restorer(&m_Pos);
ByteString nextword = GetNextWord(&bIsNumber);
- if (bIsNumber) {
- ByteString nextword2 = GetNextWord(nullptr);
- if (nextword2 == "R") {
- uint32_t refnum = FXSYS_atoui(word.c_str());
- if (refnum == CPDF_Object::kInvalidObjNum)
- return nullptr;
- return pdfium::MakeUnique<CPDF_Reference>(pObjList, refnum);
- }
- }
- m_Pos = SavedPos;
- return pdfium::MakeUnique<CPDF_Number>(word.AsStringView());
+ if (!bIsNumber)
+ return pdfium::MakeUnique<CPDF_Number>(word.AsStringView());
+
+ ByteString nextword2 = GetNextWord(nullptr);
+ if (nextword2 != "R")
+ return pdfium::MakeUnique<CPDF_Number>(word.AsStringView());
+
+ pos_restorer.AbandonRestoration();
+ uint32_t refnum = FXSYS_atoui(word.c_str());
+ if (refnum == CPDF_Object::kInvalidObjNum)
+ return nullptr;
+
+ return pdfium::MakeUnique<CPDF_Reference>(pObjList, refnum);
}
if (word == "true" || word == "false")
@@ -453,12 +455,10 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectBodyInternal(
}
}
- FX_FILESIZE SavedPos = m_Pos;
- ByteString nextword = GetNextWord(nullptr);
- if (nextword != "stream") {
- m_Pos = SavedPos;
+ AutoRestorer<FX_FILESIZE> pos_restorer(&m_Pos);
+ if (GetNextWord(nullptr) != "stream")
return std::move(pDict);
- }
+ pos_restorer.AbandonRestoration();
return ReadStream(std::move(pDict));
}
if (word == ">>")