From f07437fb5a6cca07c10bafa78365456eb1d6d5e1 Mon Sep 17 00:00:00 2001 From: Jonathan Reams Date: Tue, 29 Nov 2016 11:03:25 -0500 Subject: SERVER-27177 initialize kCurrentScope before creating mozjs runtime/scope (cherry picked from commit 7cb646696ba926a577a23572afa857b4360b9bac) --- src/mongo/scripting/mozjs/implscope.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mongo/scripting/mozjs/implscope.cpp b/src/mongo/scripting/mozjs/implscope.cpp index 6a250c0b897..72de902359a 100644 --- a/src/mongo/scripting/mozjs/implscope.cpp +++ b/src/mongo/scripting/mozjs/implscope.cpp @@ -246,6 +246,10 @@ void MozJSImplScope::_gcCallback(JSRuntime* rt, JSGCStatus status, void* data) { } MozJSImplScope::MozRuntime::MozRuntime(const MozJSScriptEngine* engine) { + // While we're initializing the runtime/scope, calling MozJSImplScope::getThreadScope() should + // return a nullptr. + kCurrentScope = nullptr; + /** * The maximum amount of memory to be given out per thread to mozilla. We * manage this by trapping all calls to malloc, free, etc. and keeping track of -- cgit v1.2.1