diff options
Diffstat (limited to 'src/mongo/scripting/mozjs/nativefunction.cpp')
-rw-r--r-- | src/mongo/scripting/mozjs/nativefunction.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/mongo/scripting/mozjs/nativefunction.cpp b/src/mongo/scripting/mozjs/nativefunction.cpp index ef5423f0f21..4d019a5b347 100644 --- a/src/mongo/scripting/mozjs/nativefunction.cpp +++ b/src/mongo/scripting/mozjs/nativefunction.cpp @@ -78,6 +78,8 @@ void NativeFunctionInfo::call(JSContext* cx, JS::CallArgs args) { } BSONObjBuilder bob; + JS::RootedObject robj(cx, JS_NewPlainObject(cx)); + ObjectWrapper wobj(cx, robj); for (unsigned i = 0; i < args.length(); i++) { // 11 is enough here. unsigned's are only 32 bits, and 1 << 32 is only @@ -85,10 +87,10 @@ void NativeFunctionInfo::call(JSContext* cx, JS::CallArgs args) { char buf[11]; std::sprintf(buf, "%i", i); - ValueWriter(cx, args.get(i)).writeThis(&bob, buf); + wobj.setValue(buf, args.get(i)); } - BSONObj out = holder->_func(bob.obj(), holder->_ctx); + BSONObj out = holder->_func(wobj.toBSON(), holder->_ctx); ValueReader(cx, args.rval()).fromBSONElement(out.firstElement(), false); } |