diff options
author | weili <weili@chromium.org> | 2016-08-23 21:10:57 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-23 21:10:57 -0700 |
commit | 0dadcc6fdab7ad1f2ee95d763f31aad5d3534f93 (patch) | |
tree | d62cd8cc5b33e8b3707bbdb6eb5bbf6269f52110 /testing/embedder_test.h | |
parent | e07edce5b253bc4f2bef6888c5b1cbf0b320a919 (diff) | |
download | pdfium-0dadcc6fdab7ad1f2ee95d763f31aad5d3534f93.tar.xz |
Fix page leaks in an embedder test
Embedder test's delegate function GetPage() calls FPDF_LoadPage() to
load a page which may be already loaded by embedder test itself.
Thus the page's ref count is increased unnecessarily.
This causes the page to be leaked. Fix this by putting the page map in
embedder test class and guarantee the page is loaded only once.
Also, fix leaks in this embedder tests by unloading the loaded pages to
properly release the resource.
BUG=pdfium:242
Review-Url: https://codereview.chromium.org/2258333002
Diffstat (limited to 'testing/embedder_test.h')
-rw-r--r-- | testing/embedder_test.h | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/testing/embedder_test.h b/testing/embedder_test.h index 6b814a7267..153ca6e5f3 100644 --- a/testing/embedder_test.h +++ b/testing/embedder_test.h @@ -51,12 +51,9 @@ class EmbedderTest : public ::testing::Test, virtual void KillTimer(int id) {} // Equivalent to FPDF_FORMFILLINFO::FFI_GetPage(). - virtual FPDF_PAGE GetPage(FPDF_FORMHANDLE form_handle, + virtual FPDF_PAGE GetPage(FPDF_FORMFILLINFO* info, FPDF_DOCUMENT document, int page_index); - - private: - std::map<int, FPDF_PAGE> m_pageMap; }; EmbedderTest(); @@ -101,10 +98,6 @@ class EmbedderTest : public ::testing::Test, // Load a specific page of the open document. virtual FPDF_PAGE LoadPage(int page_number); - // Load a specific page of the open document using delegate_->GetPage. - // delegate_->GetPage also caches loaded page. - virtual FPDF_PAGE LoadAndCachePage(int page_number); - // Convert a loaded page into a bitmap. virtual FPDF_BITMAP RenderPage(FPDF_PAGE page); @@ -130,6 +123,7 @@ class EmbedderTest : public ::testing::Test, TestLoader* loader_; size_t file_length_; std::unique_ptr<char, pdfium::FreeDeleter> file_contents_; + std::map<int, FPDF_PAGE> page_map_; private: static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type); |