diff options
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_embeddertest.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfformfill_embeddertest.cpp | 1 | ||||
-rw-r--r-- | fpdfsdk/src/fpdftext_embeddertest.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfview_embeddertest.cpp | 1 | ||||
-rw-r--r-- | samples/pdfium_test.cc | 2 | ||||
-rw-r--r-- | testing/embedder_test.cpp | 26 |
6 files changed, 22 insertions, 20 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_embeddertest.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_embeddertest.cpp index e00887ff5f..882a915edd 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_embeddertest.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_embeddertest.cpp @@ -16,5 +16,7 @@ TEST_F(FPDFParserEmbeddertest, LoadError_454695) { TEST_F(FPDFParserEmbeddertest, Bug_481363) { // Test colorspace object with malformed dictionary. EXPECT_TRUE(OpenDocument("testing/resources/bug_481363.pdf")); - EXPECT_NE(nullptr, LoadPage(0)); + FPDF_PAGE page = LoadPage(0); + EXPECT_NE(nullptr, page); + UnloadPage(page); } diff --git a/fpdfsdk/src/fpdfformfill_embeddertest.cpp b/fpdfsdk/src/fpdfformfill_embeddertest.cpp index 7c3988c445..b4cc111a00 100644 --- a/fpdfsdk/src/fpdfformfill_embeddertest.cpp +++ b/fpdfsdk/src/fpdfformfill_embeddertest.cpp @@ -24,4 +24,5 @@ TEST_F(FPDFFormFillEmbeddertest, FirstTest) { EXPECT_TRUE(OpenDocument("testing/resources/hello_world.pdf")); FPDF_PAGE page = LoadPage(0); EXPECT_NE(nullptr, page); + UnloadPage(page); } diff --git a/fpdfsdk/src/fpdftext_embeddertest.cpp b/fpdfsdk/src/fpdftext_embeddertest.cpp index 394e1a96b3..8384a41944 100644 --- a/fpdfsdk/src/fpdftext_embeddertest.cpp +++ b/fpdfsdk/src/fpdftext_embeddertest.cpp @@ -36,7 +36,7 @@ TEST_F(FPDFTextEmbeddertest, Text) { FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page); EXPECT_NE(nullptr, textpage); - const char expected[] = "Hello, world!\r\nGoodbye, world!"; + static const char expected[] = "Hello, world!\r\nGoodbye, world!"; unsigned short fixed_buffer[128]; memset(fixed_buffer, 0xbd, sizeof(fixed_buffer)); @@ -134,6 +134,7 @@ TEST_F(FPDFTextEmbeddertest, Text) { EXPECT_EQ(0xbdbd, fixed_buffer[10]); FPDFText_ClosePage(textpage); + UnloadPage(page); } TEST_F(FPDFTextEmbeddertest, TextSearch) { @@ -239,6 +240,7 @@ TEST_F(FPDFTextEmbeddertest, TextSearch) { FPDFText_FindClose(search); FPDFText_ClosePage(textpage); + UnloadPage(page); } // Test that the page has characters despite a bad stream length. @@ -252,6 +254,7 @@ TEST_F(FPDFTextEmbeddertest, StreamLengthPastEndOfFile) { EXPECT_EQ(13, FPDFText_CountChars(textpage)); FPDFText_ClosePage(textpage); + UnloadPage(page); } TEST_F(FPDFTextEmbeddertest, WebLinks) { @@ -277,7 +280,7 @@ TEST_F(FPDFTextEmbeddertest, WebLinks) { EXPECT_EQ(25, FPDFLink_GetURL(pagelink, 0, nullptr, 0)); EXPECT_EQ(26, FPDFLink_GetURL(pagelink, 1, nullptr, 0)); - const char expected_url[] = "http://example.com?q=foo"; + static const char expected_url[] = "http://example.com?q=foo"; unsigned short fixed_buffer[128]; // Retrieve a link with too small a buffer. Buffer will not be @@ -358,4 +361,5 @@ TEST_F(FPDFTextEmbeddertest, WebLinks) { FPDFLink_CloseWebLinks(pagelink); FPDFText_ClosePage(textpage); + UnloadPage(page); } diff --git a/fpdfsdk/src/fpdfview_embeddertest.cpp b/fpdfsdk/src/fpdfview_embeddertest.cpp index f885aa663a..cc0aa1f818 100644 --- a/fpdfsdk/src/fpdfview_embeddertest.cpp +++ b/fpdfsdk/src/fpdfview_embeddertest.cpp @@ -194,6 +194,7 @@ TEST_F(FPDFViewEmbeddertest, Crasher_452455) { EXPECT_TRUE(OpenDocument("testing/resources/bug_452455.pdf")); FPDF_PAGE page = LoadPage(0); EXPECT_NE(nullptr, page); + UnloadPage(page); } TEST_F(FPDFViewEmbeddertest, Crasher3) { diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index a3cc645db3..a91e132506 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -550,8 +550,8 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len, } FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC); - FPDFDOC_ExitFormFillEnvironment(form); FPDF_CloseDocument(doc); + FPDFDOC_ExitFormFillEnvironment(form); FPDFAvail_Destroy(pdf_avail); fprintf(stderr, "Rendered %d pages.\n", rendered_pages); diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp index 4cf7a8db8a..9b21609978 100644 --- a/testing/embedder_test.cpp +++ b/testing/embedder_test.cpp @@ -36,24 +36,24 @@ static char* GetFileContents(const char* filename, size_t* retlen) { FILE* file = fopen(filename, "rb"); if (!file) { fprintf(stderr, "Failed to open: %s\n", filename); - return NULL; + return nullptr; } (void) fseek(file, 0, SEEK_END); size_t file_length = ftell(file); if (!file_length) { - return NULL; + return nullptr; } (void) fseek(file, 0, SEEK_SET); char* buffer = (char*) malloc(file_length); if (!buffer) { - return NULL; + return nullptr; } size_t bytes_read = fread(buffer, 1, file_length, file); (void) fclose(file); if (bytes_read != file_length) { fprintf(stderr, "Failed to read: %s\n", filename); free(buffer); - return NULL; + return nullptr; } *retlen = bytes_read; return buffer; @@ -211,21 +211,15 @@ void EmbedderTest::SetUp() { } void EmbedderTest::TearDown() { - if (form_handle_) { - FORM_DoDocumentAAction(form_handle_, FPDFDOC_AACTION_WC); - FPDFDOC_ExitFormFillEnvironment(form_handle_); - } if (document_) { + FORM_DoDocumentAAction(form_handle_, FPDFDOC_AACTION_WC); FPDF_CloseDocument(document_); + FPDFDOC_ExitFormFillEnvironment(form_handle_); } FPDFAvail_Destroy(avail_); FPDF_DestroyLibrary(); - if (loader_) { - delete loader_; - } - if (file_contents_) { - free(file_contents_); - } + delete loader_; + free(file_contents_); } bool EmbedderTest::OpenDocument(const std::string& filename) { @@ -249,9 +243,9 @@ bool EmbedderTest::OpenDocument(const std::string& filename) { (void) FPDFAvail_IsDocAvail(avail_, &hints_); if (!FPDFAvail_IsLinearized(avail_)) { - document_ = FPDF_LoadCustomDocument(&file_access_, NULL); + document_ = FPDF_LoadCustomDocument(&file_access_, nullptr); } else { - document_ = FPDFAvail_GetDocument(avail_, NULL); + document_ = FPDFAvail_GetDocument(avail_, nullptr); } (void) FPDF_GetDocPermissions(document_); |