From 3f3c39d04fd68d8ce11f52baa3acae8e0522a2c4 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 1 May 2018 17:46:34 +0000 Subject: Check for NULL XFA context even when XFA Use strict typing for FPDF_Page to ensure we don't fall into code that expects the other page type when continuing from null context case. Change-Id: I7f028ef3e3d733f5557620030a87e22997da00d5 Reviewed-on: https://pdfium-review.googlesource.com/31770 Commit-Queue: Tom Sepez Reviewed-by: dsinclair --- fpdfsdk/fpdf_save.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'fpdfsdk/fpdf_save.cpp') diff --git a/fpdfsdk/fpdf_save.cpp b/fpdfsdk/fpdf_save.cpp index 2844f5a965..e4a1a607bb 100644 --- a/fpdfsdk/fpdf_save.cpp +++ b/fpdfsdk/fpdf_save.cpp @@ -227,10 +227,11 @@ bool FPDF_Doc_Save(FPDF_DOCUMENT document, return 0; #ifdef PDF_ENABLE_XFA - CPDFXFA_Context* pContext = - static_cast(pPDFDoc->GetExtension()); - std::vector> fileList; - SendPreSaveToXFADoc(pContext, &fileList); + auto* pContext = static_cast(pPDFDoc->GetExtension()); + if (pContext) { + std::vector> fileList; + SendPreSaveToXFADoc(pContext, &fileList); + } #endif // PDF_ENABLE_XFA if (flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY) @@ -246,9 +247,11 @@ bool FPDF_Doc_Save(FPDF_DOCUMENT document, } bool bRet = fileMaker.Create(flags); + #ifdef PDF_ENABLE_XFA SendPostSaveToXFADoc(pContext); #endif // PDF_ENABLE_XFA + return bRet; } -- cgit v1.2.3