From 825f29ce7a61fc5d0ea12c5fd7aaa88984adb965 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 3 Jul 2018 13:41:34 +0000 Subject: Use GetPos() and SetPos() in CPDF_SyntaxParser::ReadStream(). Change-Id: I711508cdffd9756837657390d73b88c2d8c62db5 Reviewed-on: https://pdfium-review.googlesource.com/36891 Commit-Queue: dsinclair Reviewed-by: Art Snake Reviewed-by: dsinclair --- core/fpdfapi/parser/cpdf_syntax_parser.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index 09ed011cda..afdac58257 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -525,19 +525,19 @@ std::unique_ptr CPDF_SyntaxParser::ReadStream( // Locate the start of stream. ToNextLine(); - FX_FILESIZE streamStartPos = m_Pos; + FX_FILESIZE streamStartPos = GetPos(); const ByteStringView kEndStreamStr("endstream"); const ByteStringView kEndObjStr("endobj"); bool bSearchForKeyword = true; if (len >= 0) { - pdfium::base::CheckedNumeric pos = m_Pos; + pdfium::base::CheckedNumeric pos = GetPos(); pos += len; if (pos.IsValid() && pos.ValueOrDie() < m_FileLen) m_Pos = pos.ValueOrDie(); - m_Pos += ReadEOLMarkers(m_Pos); + m_Pos += ReadEOLMarkers(GetPos()); memset(m_WordBuffer, 0, kEndStreamStr.GetLength() + 1); GetNextWordInternal(nullptr); // Earlier version of PDF specification doesn't require EOL marker before @@ -562,9 +562,9 @@ std::unique_ptr CPDF_SyntaxParser::ReadStream( break; // Stop searching when "endstream" is found. - if (IsWholeWord(m_Pos - kEndStreamStr.GetLength(), m_FileLen, + if (IsWholeWord(GetPos() - kEndStreamStr.GetLength(), m_FileLen, kEndStreamStr, true)) { - endStreamOffset = m_Pos - streamStartPos - kEndStreamStr.GetLength(); + endStreamOffset = GetPos() - streamStartPos - kEndStreamStr.GetLength(); break; } } @@ -579,9 +579,9 @@ std::unique_ptr CPDF_SyntaxParser::ReadStream( break; // Stop searching when "endobj" is found. - if (IsWholeWord(m_Pos - kEndObjStr.GetLength(), m_FileLen, kEndObjStr, + if (IsWholeWord(GetPos() - kEndObjStr.GetLength(), m_FileLen, kEndObjStr, true)) { - endObjOffset = m_Pos - streamStartPos - kEndObjStr.GetLength(); + endObjOffset = GetPos() - streamStartPos - kEndObjStr.GetLength(); break; } } @@ -620,7 +620,7 @@ std::unique_ptr CPDF_SyntaxParser::ReadStream( // Read up to the end of the buffer. Note, we allow zero length streams as // we need to pass them through when we are importing pages into a new // document. - len = std::min(len, m_FileLen - m_Pos - m_HeaderOffset); + len = std::min(len, m_FileLen - GetPos() - m_HeaderOffset); if (len < 0) return nullptr; @@ -631,11 +631,11 @@ std::unique_ptr CPDF_SyntaxParser::ReadStream( } auto pStream = pdfium::MakeUnique(std::move(pData), len, std::move(pDict)); - streamStartPos = m_Pos; + streamStartPos = GetPos(); memset(m_WordBuffer, 0, kEndObjStr.GetLength() + 1); GetNextWordInternal(nullptr); - int numMarkers = ReadEOLMarkers(m_Pos); + int numMarkers = ReadEOLMarkers(GetPos()); if (m_WordSize == static_cast(kEndObjStr.GetLength()) && numMarkers != 0 && memcmp(m_WordBuffer, kEndObjStr.raw_str(), kEndObjStr.GetLength()) == 0) { -- cgit v1.2.3