summaryrefslogtreecommitdiff
path: root/testing/test_support.cpp
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-06-27 09:47:59 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-27 09:47:59 -0700
commitc08cd7abb2069b6056ec99c8ec5b87524e45df01 (patch)
treea1b919599cd5f3f23aeb9834aff5b6d21c7549ec /testing/test_support.cpp
parentdff03da3d403b72098d5d43ea90b03ed340de5ec (diff)
downloadpdfium-c08cd7abb2069b6056ec99c8ec5b87524e45df01.tar.xz
Fix memory leaks with V8 startup data.
Review-Url: https://codereview.chromium.org/2068563002
Diffstat (limited to 'testing/test_support.cpp')
-rw-r--r--testing/test_support.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/testing/test_support.cpp b/testing/test_support.cpp
index 96a18a547a..c4d915e900 100644
--- a/testing/test_support.cpp
+++ b/testing/test_support.cpp
@@ -157,12 +157,14 @@ bool InitializeV8ForPDFium(const std::string& exe_path,
v8::StartupData* snapshot_blob,
v8::Platform** platform) {
InitializeV8Common(exe_path.c_str(), platform);
- if (!GetExternalData(exe_path, bin_dir, "natives_blob.bin", natives_blob))
- return false;
- if (!GetExternalData(exe_path, bin_dir, "snapshot_blob.bin", snapshot_blob))
- return false;
- v8::V8::SetNativesDataBlob(natives_blob);
- v8::V8::SetSnapshotDataBlob(snapshot_blob);
+ if (natives_blob && snapshot_blob) {
+ if (!GetExternalData(exe_path, bin_dir, "natives_blob.bin", natives_blob))
+ return false;
+ if (!GetExternalData(exe_path, bin_dir, "snapshot_blob.bin", snapshot_blob))
+ return false;
+ v8::V8::SetNativesDataBlob(natives_blob);
+ v8::V8::SetSnapshotDataBlob(snapshot_blob);
+ }
return true;
}
#else // V8_USE_EXTERNAL_STARTUP_DATA