summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/jsapi
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-02 08:59:57 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-02 08:59:57 -0700
commit8b315b6d81c232b393c6034e2d272437104b0f57 (patch)
tree481b22ad2eb80537226175f616bd999e7e1cf60c /fpdfsdk/src/jsapi
parent028ded15d2a90b8d1c20a49648054c6b34ee039a (diff)
downloadpdfium-8b315b6d81c232b393c6034e2d272437104b0f57.tar.xz
Merge to XFA: Fix static initializer in fxjs_v8.cpp
(cherry picked from commit 20fc82efdc9c9e4caa6e72d05a83b9206e8c8f72) Original Review URL: https://codereview.chromium.org/1372103004 . TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1383033002 .
Diffstat (limited to 'fpdfsdk/src/jsapi')
-rw-r--r--fpdfsdk/src/jsapi/fxjs_v8.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp
index ffe04bbfe5..b4b9929265 100644
--- a/fpdfsdk/src/jsapi/fxjs_v8.cpp
+++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp
@@ -24,7 +24,7 @@ static unsigned int g_embedderDataSlot = 1u;
// kPerContextDataStartIndex + kEmbedderPDFium, which is 3.
static const unsigned int kPerContextDataIndex = 3u;
-static v8::Global<v8::ObjectTemplate> g_DefaultGlobalObjectTemplate;
+static v8::Global<v8::ObjectTemplate>* g_DefaultGlobalObjectTemplate = nullptr;
class CFXJS_PrivateData {
public:
@@ -111,11 +111,12 @@ static v8::Local<v8::ObjectTemplate> GetGlobalObjectTemplate(
return pObjDef->GetInstanceTemplate();
}
- if (g_DefaultGlobalObjectTemplate.IsEmpty())
- g_DefaultGlobalObjectTemplate.Reset(pIsolate,
- v8::ObjectTemplate::New(pIsolate));
-
- return g_DefaultGlobalObjectTemplate.Get(pIsolate);
+ if (!g_DefaultGlobalObjectTemplate) {
+ g_DefaultGlobalObjectTemplate = new v8::Global<v8::ObjectTemplate>;
+ g_DefaultGlobalObjectTemplate->Reset(pIsolate,
+ v8::ObjectTemplate::New(pIsolate));
+ }
+ return g_DefaultGlobalObjectTemplate->Get(pIsolate);
}
void* FXJS_ArrayBufferAllocator::Allocate(size_t length) {