Pass retained arguments to CPDF_StreamContentParser() constructor
Bug: pdfium:1843
Change-Id: I053933eaa31bb16367c44a85b9006e50b45b7469
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/95412
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index a1ddf12..4be90f2 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -6,6 +6,8 @@
#include "core/fpdfapi/page/cpdf_contentparser.h"
+#include <utility>
+
#include "constants/page_object.h"
#include "core/fpdfapi/font/cpdf_type3char.h"
#include "core/fpdfapi/page/cpdf_allstates.h"
@@ -86,9 +88,9 @@
RetainPtr<CPDF_Dictionary> pResources =
pForm->GetMutableDict()->GetMutableDictFor("Resources");
m_pParser = std::make_unique<CPDF_StreamContentParser>(
- pForm->GetDocument(), pForm->GetMutablePageResources().Get(),
- pForm->GetMutableResources().Get(), pParentMatrix, pForm,
- pResources.Get(), form_bbox, pGraphicStates, pParsedSet);
+ pForm->GetDocument(), pForm->GetMutablePageResources(),
+ pForm->GetMutableResources(), pParentMatrix, pForm, std::move(pResources),
+ form_bbox, pGraphicStates, pParsedSet);
m_pParser->GetCurStates()->m_CTM = form_matrix;
m_pParser->GetCurStates()->m_ParentMatrix = form_matrix;
if (ClipPath.HasRef()) {
@@ -192,8 +194,8 @@
m_ParsedSet.clear();
m_pParser = std::make_unique<CPDF_StreamContentParser>(
m_pObjectHolder->GetDocument(),
- m_pObjectHolder->GetMutablePageResources().Get(), nullptr, nullptr,
- m_pObjectHolder.Get(), m_pObjectHolder->GetMutableResources().Get(),
+ m_pObjectHolder->GetMutablePageResources(), nullptr, nullptr,
+ m_pObjectHolder.Get(), m_pObjectHolder->GetMutableResources(),
m_pObjectHolder->GetBBox(), nullptr, &m_ParsedSet);
m_pParser->GetCurStates()->m_ColorState.SetDefault();
}
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 8523006..b2a80ce 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -242,20 +242,20 @@
CPDF_StreamContentParser::CPDF_StreamContentParser(
CPDF_Document* pDocument,
- CPDF_Dictionary* pPageResources,
- CPDF_Dictionary* pParentResources,
+ RetainPtr<CPDF_Dictionary> pPageResources,
+ RetainPtr<CPDF_Dictionary> pParentResources,
const CFX_Matrix* pmtContentToUser,
CPDF_PageObjectHolder* pObjHolder,
- CPDF_Dictionary* pResources,
+ RetainPtr<CPDF_Dictionary> pResources,
const CFX_FloatRect& rcBBox,
const CPDF_AllStates* pStates,
std::set<const uint8_t*>* pParsedSet)
: m_pDocument(pDocument),
m_pPageResources(pPageResources),
m_pParentResources(pParentResources),
- m_pResources(CPDF_Form::ChooseResourcesDict(pResources,
- pParentResources,
- pPageResources)),
+ m_pResources(CPDF_Form::ChooseResourcesDict(pResources.Get(),
+ pParentResources.Get(),
+ pPageResources.Get())),
m_pObjectHolder(pObjHolder),
m_ParsedSet(pParsedSet),
m_BBox(rcBBox),
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index 8879c85..09c3587 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -42,11 +42,11 @@
class CPDF_StreamContentParser {
public:
CPDF_StreamContentParser(CPDF_Document* pDoc,
- CPDF_Dictionary* pPageResources,
- CPDF_Dictionary* pParentResources,
+ RetainPtr<CPDF_Dictionary> pPageResources,
+ RetainPtr<CPDF_Dictionary> pParentResources,
const CFX_Matrix* pmtContentToUser,
CPDF_PageObjectHolder* pObjHolder,
- CPDF_Dictionary* pResources,
+ RetainPtr<CPDF_Dictionary> pResources,
const CFX_FloatRect& rcBBox,
const CPDF_AllStates* pStates,
std::set<const uint8_t*>* pParsedSet);