summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-02-06 00:18:12 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-06 00:18:12 +0000
commit8e53c8c8e19a1f40d90f47068c7dd7ee6ffa275d (patch)
tree0f95c3ae75b84069743c6d8e38a0e39d1281c0d9
parent29561e53b60c680e4f6fca9d91047952b2de7906 (diff)
downloadpdfium-8e53c8c8e19a1f40d90f47068c7dd7ee6ffa275d.tar.xz
Fix an infinite recursion in pdfium_test.
Mark pages as loaded before calling FORM_DoPageAAction(). BUG=chromium:808898 Change-Id: I82c481ba759842ea794b5578120101465b37f16a Reviewed-on: https://pdfium-review.googlesource.com/25511 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r--samples/pdfium_test.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index 707fbb1028..ebc7412055 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -987,15 +987,18 @@ FPDF_PAGE GetPageForIndex(FPDF_FORMFILLINFO* param,
if (iter != loaded_pages.end())
return iter->second.get();
- FPDF_PAGE page = FPDF_LoadPage(doc, index);
+ std::unique_ptr<void, FPDFPageDeleter> page(FPDF_LoadPage(doc, index));
if (!page)
return nullptr;
+ // Mark the page as loaded first to prevent infinite recursion.
+ FPDF_PAGE page_ptr = page.get();
+ loaded_pages[index] = std::move(page);
+
FPDF_FORMHANDLE& form_handle = form_fill_info->form_handle;
- FORM_OnAfterLoadPage(page, form_handle);
- FORM_DoPageAAction(page, form_handle, FPDFPAGE_AACTION_OPEN);
- loaded_pages[index].reset(page);
- return page;
+ FORM_OnAfterLoadPage(page_ptr, form_handle);
+ FORM_DoPageAAction(page_ptr, form_handle, FPDFPAGE_AACTION_OPEN);
+ return page_ptr;
}
std::wstring ConvertToWString(const unsigned short* buf,