summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_view.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-05-31 23:38:32 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-31 23:38:32 +0000
commit2d11d72e326140b9abeb6de2db1e28e5bf9d7e64 (patch)
treeffd41a61a342924bded55443d6a478b3f8caee0f /fpdfsdk/fpdf_view.cpp
parent73659ee409ae4840c5019633a5c4000eececd7c0 (diff)
downloadpdfium-2d11d72e326140b9abeb6de2db1e28e5bf9d7e64.tar.xz
Make CPDF_Document own its Extension.
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 <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_view.cpp')
-rw-r--r--fpdfsdk/fpdf_view.cpp14
1 files changed, 3 insertions, 11 deletions
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 <memory>
#include <utility>
#include <vector>
@@ -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<CPDF_Document>(CPDFDocumentFromFPDFDocument(document));
}
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetLastError() {