diff options
author | weili <weili@chromium.org> | 2016-08-19 16:19:46 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-19 16:19:46 -0700 |
commit | 9b777deb00fb50dba37ccc1ee69767c6e04a3ee4 (patch) | |
tree | 5563d0ad14fab5decc89be923c1d9cc330cb20d1 | |
parent | 19ecc23e30f0d5368a703d751afd718a0c6434f6 (diff) | |
download | pdfium-9b777deb00fb50dba37ccc1ee69767c6e04a3ee4.tar.xz |
Fix an embedder test with leaked page objectchromium/2836chromium/2835
The public API FPDFPage_New() incorrectly said to use FPDFPage_Delete()
instead of FPDF_ClosePage() to free the new page. This led to a page object
leak in an embedder test. Correct the public API description
as well as its usage in the embedder test.
BUG=pdfium:242
Review-Url: https://codereview.chromium.org/2260683003
-rw-r--r-- | fpdfsdk/fpdfedit_embeddertest.cpp | 4 | ||||
-rw-r--r-- | public/fpdf_edit.h | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp index 720dcdec01..34b5993879 100644 --- a/fpdfsdk/fpdfedit_embeddertest.cpp +++ b/fpdfsdk/fpdfedit_embeddertest.cpp @@ -55,7 +55,7 @@ const char kExpectedPDF[] = TEST_F(FPDFEditEmbeddertest, EmptyCreation) { EXPECT_TRUE(CreateEmptyDocument()); - FPDF_PAGE page = FPDFPage_New(document(), 1, 640.0, 480.0); + FPDF_PAGE page = FPDFPage_New(document(), 0, 640.0, 480.0); EXPECT_NE(nullptr, page); EXPECT_TRUE(FPDFPage_GenerateContent(page)); EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0)); @@ -66,5 +66,5 @@ TEST_F(FPDFEditEmbeddertest, EmptyCreation) { std::replace(result.begin(), result.end(), '\0', '_'); EXPECT_THAT(result, testing::MatchesRegex( std::string(kExpectedPDF, sizeof(kExpectedPDF)))); - FPDFPage_Delete(document(), 1); + FPDF_ClosePage(page); } diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h index acec6c0d30..47fdf9e76e 100644 --- a/public/fpdf_edit.h +++ b/public/fpdf_edit.h @@ -38,13 +38,16 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument(); // Create a new PDF page. // // document - handle to document. -// page_index - the index of the page to create. +// page_index - suggested index of the page to create. If it is larger than +// document's current last index(L), the created page index is +// the next available index -- L+1. // width - the page width. // height - the page height. // // Returns the handle to the new page. // -// The page should be deleted with |FPDFPage_Delete| when finished. +// The page should be closed with CPDF_ClosePage() when finished as +// with any other page in the document. DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index, double width, |