From 6c4ca9f597ae84550e0b8a4323e44b188f9bb274 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Thu, 5 Jul 2018 16:55:48 +0000 Subject: Delete CPDF_ContentMark::HasRef() This is called by many client to make sure CountItems() does not crash. Moving the check to CountItems() makes HasRef() unnecessary. Bug: pdfium:1037 Change-Id: I4f21f33a88c9aad54f0dae18a38b370c6ceaec80 Reviewed-on: https://pdfium-review.googlesource.com/37133 Commit-Queue: Henrique Nakashima Reviewed-by: Ryan Harrison --- core/fpdfapi/page/cpdf_contentmark.cpp | 3 +++ core/fpdfapi/page/cpdf_contentmark.h | 2 -- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 6 ++---- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmark.cpp index 77c29a53d7..a4bb15ed9a 100644 --- a/core/fpdfapi/page/cpdf_contentmark.cpp +++ b/core/fpdfapi/page/cpdf_contentmark.cpp @@ -23,6 +23,9 @@ std::unique_ptr CPDF_ContentMark::Clone() { } size_t CPDF_ContentMark::CountItems() const { + if (!m_Ref) + return 0; + return m_Ref->CountItems(); } diff --git a/core/fpdfapi/page/cpdf_contentmark.h b/core/fpdfapi/page/cpdf_contentmark.h index 241a0ffbf3..6012350398 100644 --- a/core/fpdfapi/page/cpdf_contentmark.h +++ b/core/fpdfapi/page/cpdf_contentmark.h @@ -29,8 +29,6 @@ class CPDF_ContentMark { void AddMark(ByteString name, const CPDF_Dictionary* pDict, bool bDirect); void DeleteLastMark(); - bool HasRef() const { return !!m_Ref; } - private: class MarkData : public Retainable { public: diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index b2ac553191..c698c52370 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -868,10 +868,8 @@ void CPDF_StreamContentParser::Handle_MarkPlace_Dictionary() {} void CPDF_StreamContentParser::Handle_EndImage() {} void CPDF_StreamContentParser::Handle_EndMarkedContent() { - if (m_pCurContentMark->HasRef()) { - m_pCurContentMark = m_pCurContentMark->Clone(); - m_pCurContentMark->DeleteLastMark(); - } + m_pCurContentMark = m_pCurContentMark->Clone(); + m_pCurContentMark->DeleteLastMark(); } void CPDF_StreamContentParser::Handle_EndText() { -- cgit v1.2.3