summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-05-15 15:36:02 -0700
committerLei Zhang <thestig@chromium.org>2015-05-15 15:36:02 -0700
commitd27acae33ff902ee85ae4f8ec76d4f64c294637b (patch)
tree44506c7c78a15dfee730b2ff3e6e675e561b510a /testing
parentb6e5df2eded21ca142adf43b4f78a9027589bfeb (diff)
downloadpdfium-d27acae33ff902ee85ae4f8ec76d4f64c294637b.tar.xz
Merge to XFA: Fix leaks in the embedder tests themselves.
Also change EmbedderTest::TearDown() to match the destruction order in Chromium's PDF code. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1138143003 (cherry picked from commit 61ffad8df484ab9b3f7d2f5519ec470fbc023b88) Review URL: https://codereview.chromium.org/1138973004
Diffstat (limited to 'testing')
-rw-r--r--testing/embedder_test.cpp26
1 files changed, 10 insertions, 16 deletions
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;