From 862cbe46b7d7040e35733f5ed63839ee34223387 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 27 Apr 2018 19:32:59 +0000 Subject: Avoid potential duplicate unique_ptr to CPDF_Document from CPDFXA_Context. Should FPDFDocumentFromCPDFDocument() be called several times under XFA, we may WrapUnique() the document several times. So cache a pointer back from CPDF_Document to CPDFXFA_Context to avoid this. Because of layering, introduce a placeholder type CPDF_Document::Extension. This is actually the first step in some larger XFA ownership cleanup, but makes a nice standalone CL around the one particular issue. Change-Id: I4be326ddb1a5fae7339e6ed6745dd551b1374b53 Reviewed-on: https://pdfium-review.googlesource.com/31570 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fpdfapi/parser/cpdf_document.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'core/fpdfapi') diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h index d73dbc1df9..adf4eca75d 100644 --- a/core/fpdfapi/parser/cpdf_document.h +++ b/core/fpdfapi/parser/cpdf_document.h @@ -41,9 +41,15 @@ class JBig2_DocumentContext; class CPDF_Document : public CPDF_IndirectObjectHolder { public: + // Type from which the XFA extension can subclass itself. + class Extension {}; + explicit CPDF_Document(std::unique_ptr pParser); ~CPDF_Document() override; + Extension* GetExtension() const { return m_pExtension.Get(); } + void SetExtension(Extension* pExt) { m_pExtension = pExt; } + CPDF_Parser* GetParser() const { return m_pParser.get(); } const CPDF_Dictionary* GetRoot() const { return m_pRootDict; } CPDF_Dictionary* GetRoot() { return m_pRootDict; } @@ -153,6 +159,7 @@ class CPDF_Document : public CPDF_IndirectObjectHolder { std::unique_ptr m_pCodecContext; std::unique_ptr m_pLinksContext; std::vector m_PageList; + UnownedPtr m_pExtension; }; #endif // CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_ -- cgit v1.2.3