diff options
Diffstat (limited to 'fpdfsdk/cpdfsdk_helpers.cpp')
-rw-r--r-- | fpdfsdk/cpdfsdk_helpers.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fpdfsdk/cpdfsdk_helpers.cpp b/fpdfsdk/cpdfsdk_helpers.cpp index 4c417e15e5..040b0f2e5a 100644 --- a/fpdfsdk/cpdfsdk_helpers.cpp +++ b/fpdfsdk/cpdfsdk_helpers.cpp @@ -166,9 +166,12 @@ CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) { FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) { #ifdef PDF_ENABLE_XFA - return doc ? FPDFDocumentFromUnderlying( - new CPDFXFA_Context(pdfium::WrapUnique(doc))) - : nullptr; + if (!doc) + return nullptr; + if (!doc->GetExtension()) + doc->SetExtension(new CPDFXFA_Context(pdfium::WrapUnique(doc))); + return FPDFDocumentFromUnderlying( + static_cast<CPDFXFA_Context*>(doc->GetExtension())); #else // PDF_ENABLE_XFA return FPDFDocumentFromUnderlying(doc); #endif // PDF_ENABLE_XFA |