From 2d11d72e326140b9abeb6de2db1e28e5bf9d7e64 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 31 May 2018 23:38:32 +0000 Subject: Make CPDF_Document own its Extension. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inverting the ownership from the current situation makes cleanup much more intuitive. Change-Id: Iad9a7ca70c0746170ba753297732e3e34f96c5ba Reviewed-on: https://pdfium-review.googlesource.com/33190 Commit-Queue: Tom Sepez Reviewed-by: dsinclair Reviewed-by: Nicolás Peña Moreno --- fpdfsdk/fpdf_view.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'fpdfsdk/fpdf_view.cpp') diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp index 5304e330b7..ef242295b7 100644 --- a/fpdfsdk/fpdf_view.cpp +++ b/fpdfsdk/fpdf_view.cpp @@ -6,6 +6,7 @@ #include "public/fpdfview.h" +#include #include #include @@ -748,17 +749,8 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page) { } FPDF_EXPORT void FPDF_CALLCONV FPDF_CloseDocument(FPDF_DOCUMENT document) { - auto* pDoc = CPDFDocumentFromFPDFDocument(document); - if (!pDoc) - return; - - // Deleting the extension will delete the document - if (pDoc->GetExtension()) { - delete pDoc->GetExtension(); - return; - } - - delete pDoc; + // Take it back across the API and throw it away, + std::unique_ptr(CPDFDocumentFromFPDFDocument(document)); } FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetLastError() { -- cgit v1.2.3