diff options
-rw-r--r-- | testing/embedder_test.cpp | 8 | ||||
-rw-r--r-- | testing/embedder_test.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp index e10e2a81e8..1ce0f36a45 100644 --- a/testing/embedder_test.cpp +++ b/testing/embedder_test.cpp @@ -255,6 +255,7 @@ FPDF_PAGE EmbedderTest::LoadPage(int page_number) { FORM_DoPageAAction(page, form_handle_, FPDFPAGE_AACTION_OPEN); // Cache the page. page_map_[page_number] = page; + page_reverse_map_[page] = page_number; return page; } @@ -274,6 +275,13 @@ void EmbedderTest::UnloadPage(FPDF_PAGE page) { FORM_DoPageAAction(page, form_handle_, FPDFPAGE_AACTION_CLOSE); FORM_OnBeforeClosePage(page, form_handle_); FPDF_ClosePage(page); + + auto it = page_reverse_map_.find(page); + if (it == page_reverse_map_.end()) + return; + + page_map_.erase(it->second); + page_reverse_map_.erase(it); } FPDF_PAGE EmbedderTest::Delegate::GetPage(FPDF_FORMFILLINFO* info, diff --git a/testing/embedder_test.h b/testing/embedder_test.h index 153ca6e5f3..dc4ca0dc08 100644 --- a/testing/embedder_test.h +++ b/testing/embedder_test.h @@ -124,6 +124,7 @@ class EmbedderTest : public ::testing::Test, size_t file_length_; std::unique_ptr<char, pdfium::FreeDeleter> file_contents_; std::map<int, FPDF_PAGE> page_map_; + std::map<FPDF_PAGE, int> page_reverse_map_; private: static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type); |