diff options
Diffstat (limited to 'src/mongo/scripting/mozjs/cursor.cpp')
-rw-r--r-- | src/mongo/scripting/mozjs/cursor.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/mongo/scripting/mozjs/cursor.cpp b/src/mongo/scripting/mozjs/cursor.cpp index 79c1f5cf749..072e2ffb999 100644 --- a/src/mongo/scripting/mozjs/cursor.cpp +++ b/src/mongo/scripting/mozjs/cursor.cpp @@ -83,7 +83,9 @@ void CursorInfo::Functions::next::call(JSContext* cx, JS::CallArgs args) { BSONObj bson = cursor->next(); bool ro = o.hasField("_ro") ? o.getBoolean("_ro") : false; - ValueReader(cx, args.rval()).fromBSON(bson, ro); + // getOwned because cursor->next() gives us unowned bson from an internal + // buffer and we need to make a copy + ValueReader(cx, args.rval()).fromBSON(bson.getOwned(), nullptr, ro); } void CursorInfo::Functions::hasNext::call(JSContext* cx, JS::CallArgs args) { |