summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-01 17:40:14 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-01 17:40:14 -0700
commit20fc82efdc9c9e4caa6e72d05a83b9206e8c8f72 (patch)
tree498cba4f933a955d170ee7d9a6fb5a03807866ee /fpdfsdk/src
parent7886d8dcf3bc9ef9b51e733d77bd3243ef32adb8 (diff)
downloadpdfium-20fc82efdc9c9e4caa6e72d05a83b9206e8c8f72.tar.xz
Fix static initializer in fxjs_v8.cpp
R=thestig@chromium.org Review URL: https://codereview.chromium.org/1372103004 .
Diffstat (limited to 'fpdfsdk/src')
-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 a626bce345..667132fde4 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) {