From f9450a619c2df8a2cb5925393095d6044a110afc Mon Sep 17 00:00:00 2001 From: Jason Carey Date: Mon, 30 Nov 2015 10:12:29 -0500 Subject: SERVER-21692 check return of JS_NewRuntime Moved an uassert away from a call site. Opens up the chance for nullptr dereferences. --- src/mongo/scripting/mozjs/implscope.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/mongo/scripting') diff --git a/src/mongo/scripting/mozjs/implscope.cpp b/src/mongo/scripting/mozjs/implscope.cpp index 5d099a6b254..4a90bdc76d7 100644 --- a/src/mongo/scripting/mozjs/implscope.cpp +++ b/src/mongo/scripting/mozjs/implscope.cpp @@ -230,6 +230,7 @@ MozJSImplScope::MozRuntime::MozRuntime(const MozJSScriptEngine* engine) { } _runtime = JS_NewRuntime(kMaxBytesBeforeGC); + uassert(ErrorCodes::JSInterpreterFailure, "Failed to initialize JSRuntime", _runtime); // We turn on a variety of optimizations if the jit is enabled if (engine->isJITEnabled()) { @@ -259,8 +260,6 @@ MozJSImplScope::MozRuntime::MozRuntime(const MozJSScriptEngine* engine) { } } - uassert(ErrorCodes::JSInterpreterFailure, "Failed to initialize JSRuntime", _runtime); - _context = JS_NewContext(_runtime, kStackChunkSize); uassert(ErrorCodes::JSInterpreterFailure, "Failed to initialize JSContext", _context); } -- cgit v1.2.1