Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Unified Diff: testing/embedder_test.cpp

Issue 1138973004: Merge to XFA: Fix leaks in the embedder tests themselves. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@xfa
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/src/fpdfview_embeddertest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/embedder_test.cpp
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index 1c3c2feb644036c5d5e49a4ac31c1216f03a9286..29de4caad4acc62e9069b8130f78447494637e44 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;
« no previous file with comments | « fpdfsdk/src/fpdfview_embeddertest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698