Skip to content

Instantly share code, notes, and snippets.

@osheroff
Created July 13, 2011 16:32
Show Gist options
  • Save osheroff/1080695 to your computer and use it in GitHub Desktop.
Save osheroff/1080695 to your computer and use it in GitHub Desktop.
Don't crash when compile of CodeWScope fails
diff --git a/scripting/engine_spidermonkey.cpp b/scripting/engine_spidermonkey.cpp
index 88f48e3..0f36817 100644
--- a/scripting/engine_spidermonkey.cpp
+++ b/scripting/engine_spidermonkey.cpp
@@ -662,6 +662,9 @@ namespace mongo {
case CodeWScope: {
JSFunction * func = compileFunction( e.codeWScopeCode() );
+ if ( !func )
+ return JSVAL_NULL;
+
BSONObj extraScope = e.codeWScopeObject();
if ( ! extraScope.isEmpty() ) {
log() << "warning: CodeWScope doesn't transfer to db.eval" << endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment