Refcount CPDF_OCContext.
Avoids explicit deletes through CPDF_RenderOptions holding pointers
to it which may have been copy constructed. Ick.
Change-Id: Ic044b66d13bd7c5eaa53de995373858081e115ec
Reviewed-on: https://pdfium-review.googlesource.com/2451
Reviewed-by: dsinclair <dsinclair@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index 6b8cbaa..beebe65 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -127,12 +127,13 @@
options.m_bDrawAnnots = flags & FPDF_ANNOT;
#ifdef PDF_ENABLE_XFA
- options.m_pOCContext = new CPDF_OCContext(pPDFDoc, CPDF_OCContext::View);
+ options.m_pOCContext =
+ pdfium::MakeRetain<CPDF_OCContext>(pPDFDoc, CPDF_OCContext::View);
if (CPDFSDK_PageView* pPageView = pFormFillEnv->GetPageView(pPage, true))
pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip);
#else // PDF_ENABLE_XFA
- options.m_pOCContext =
- new CPDF_OCContext(pPage->m_pDocument, CPDF_OCContext::View);
+ options.m_pOCContext = pdfium::MakeRetain<CPDF_OCContext>(
+ pPage->m_pDocument, CPDF_OCContext::View);
if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
#endif // PDF_ENABLE_XFA
@@ -142,8 +143,6 @@
pDevice->Flush();
CFXBitmapFromFPDFBitmap(bitmap)->UnPreMultiply();
#endif
- delete options.m_pOCContext;
- options.m_pOCContext = nullptr;
}
} // namespace