From 6eb7939300d1bc7c31afd5086c1b93d4a7628481 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Tue, 12 Jun 2018 20:27:35 +0000 Subject: Fill m_ContentStream field in CPDF_PageObject. From the comment of CPDF_PageObject::GetContentStream(): """ Get what content stream the object was parsed from in its page. This number is the index of the content stream in the "Contents" array, or 0 if there is a single content stream. If the object is newly created, -1 is returned. If the object is spread among more than one content stream, this is the index of the last one. """ Bug: pdfium:1051 Change-Id: I9f7804af4f263dda0422e9542e025e3320ff7c31 Reviewed-on: https://pdfium-review.googlesource.com/34250 Commit-Queue: Henrique Nakashima Reviewed-by: dsinclair --- core/fpdfapi/page/cpdf_contentparser.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'core/fpdfapi/page/cpdf_contentparser.cpp') diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp index 77cfade1da..2bb376e841 100644 --- a/core/fpdfapi/page/cpdf_contentparser.cpp +++ b/core/fpdfapi/page/cpdf_contentparser.cpp @@ -164,11 +164,13 @@ CPDF_ContentParser::Stage CPDF_ContentParser::PrepareContent() { FX_SAFE_UINT32 safeSize = 0; for (const auto& stream : m_StreamArray) { + m_StreamSegmentOffsets.push_back(safeSize.ValueOrDie()); + safeSize += stream->GetSize(); safeSize += 1; + if (!safeSize.IsValid()) + return Stage::kComplete; } - if (!safeSize.IsValid()) - return Stage::kComplete; m_Size = safeSize.ValueOrDie(); m_pData.Reset( @@ -198,9 +200,12 @@ CPDF_ContentParser::Stage CPDF_ContentParser::Parse() { if (m_CurrentOffset >= m_Size) return Stage::kCheckClip; - m_CurrentOffset += - m_pParser->Parse(m_pData.Get() + m_CurrentOffset, - m_Size - m_CurrentOffset, PARSE_STEP_LIMIT); + if (m_StreamSegmentOffsets.empty()) + m_StreamSegmentOffsets.push_back(0); + + m_CurrentOffset += m_pParser->Parse(m_pData.Get() + m_CurrentOffset, + m_Size - m_CurrentOffset, + PARSE_STEP_LIMIT, m_StreamSegmentOffsets); return Stage::kParse; } -- cgit v1.2.3