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-- | testing/embedder_test.cpp | 26 |
5 files changed, 21 insertions, 19 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 9dcfa08cf1..d58399a9b1 100644 --- a/fpdfsdk/src/fpdfview_embeddertest.cpp +++ b/fpdfsdk/src/fpdfview_embeddertest.cpp @@ -195,6 +195,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, Crasher_454695) { diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp index 1c3c2feb64..29de4caad4 100644 --- a/testing/embedder_test.cpp +++ b/testing/embedder_test.cpp @@ -37,24 +37,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; @@ -215,21 +215,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_); v8::V8::ShutdownPlatform(); } @@ -254,9 +248,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); } if (!document_) { return false; |