Commit 885a59ee authored by tsepez's avatar tsepez Committed by Commit bot

PDFiumEngine::~PDFiumEngine - Unload() all pages_ before destroying any of them.

Currently, destroying a PDFiumPage triggers an Unload() which can result
in an access to other PDFiumPages. But these other pages may already have
been destroyed as a previous element via STLDeleteElements(&pages_).

Instead, unload all pages first, then destroy them all afterwards so that
no access to other pages will be attempted after the destruction of the
first one has begun.

Move the STLDeleteElements() call to the bottom, to make it more closely
mimic the ordering that might occur should pages_ someday be switched
from vector to ScopedPtrVector or similar.

BUG=384365

Review URL: https://codereview.chromium.org/544873002

Cr-Commit-Position: refs/heads/master@{#293800}
parent 1a6a4ccc
...@@ -598,7 +598,9 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) ...@@ -598,7 +598,9 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client)
} }
PDFiumEngine::~PDFiumEngine() { PDFiumEngine::~PDFiumEngine() {
STLDeleteElements(&pages_); for (size_t i = 0; i < pages_.size(); ++i)
pages_[i]->Unload();
if (doc_) { if (doc_) {
if (form_) { if (form_) {
FORM_DoDocumentAAction(form_, FPDFDOC_AACTION_WC); FORM_DoDocumentAAction(form_, FPDFDOC_AACTION_WC);
...@@ -609,6 +611,8 @@ PDFiumEngine::~PDFiumEngine() { ...@@ -609,6 +611,8 @@ PDFiumEngine::~PDFiumEngine() {
if (fpdf_availability_) if (fpdf_availability_)
FPDFAvail_Destroy(fpdf_availability_); FPDFAvail_Destroy(fpdf_availability_);
STLDeleteElements(&pages_);
} }
int PDFiumEngine::GetBlock(void* param, unsigned long position, int PDFiumEngine::GetBlock(void* param, unsigned long position,
......
...@@ -49,7 +49,6 @@ PDFiumPage::PDFiumPage(PDFiumEngine* engine, ...@@ -49,7 +49,6 @@ PDFiumPage::PDFiumPage(PDFiumEngine* engine,
} }
PDFiumPage::~PDFiumPage() { PDFiumPage::~PDFiumPage() {
Unload();
} }
void PDFiumPage::Unload() { void PDFiumPage::Unload() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment