0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00

SERVER-11525 Better error message on oversized BSON in JS

This commit is contained in:
Mathias Stearn 2013-11-05 16:52:02 -05:00
parent 47499ce542
commit 98f35d3ff6

View File

@ -1658,7 +1658,14 @@ namespace mongo {
v8::Local<v8::Value> value = o->Get(name);
v8ToMongoElement(b, sname, value, depth + 1, &originalBSON);
}
return b.obj();
const int sizeWithEOO = b.len() + 1/*EOO*/ - 4/*BSONObj::Holder ref count*/;
uassert(17260, str::stream() << "Converting from JavaScript to BSON failed: "
<< "Object size " << sizeWithEOO << " exceeds limit of "
<< BSONObjMaxUserSize << " bytes.",
sizeWithEOO <= BSONObjMaxUserSize);
return b.obj(); // Would give an uglier error than above for oversized objects.
}
// --- random utils ----