- SERVER-4025: segv in V8 when certain special objects (e.g. DBCollection) are converted from JS to BSON

- SERVER-445: cleaner code in v8
This commit is contained in:
agirbal
2011-10-05 13:48:47 -07:00
parent c2c9eeb4f1
commit ba817fbd9a
3 changed files with 30 additions and 20 deletions

View File

@@ -1471,15 +1471,14 @@ namespace mongo {
BSONObj V8Scope::v8ToMongo( v8::Handle<v8::Object> o , int depth ) {
BSONObj* originalBSON = 0;
if (o->HasNamedLookupInterceptor()) {
if (o->InternalFieldCount() > 0) {
originalBSON = unwrapBSONObj(o);
}
if ( !o->GetHiddenValue( V8STR_RO ).IsEmpty() ||
(o->HasNamedLookupInterceptor() && o->GetHiddenValue( V8STR_MODIFIED ).IsEmpty()) ) {
// object was readonly, use bson as is
if (originalBSON)
if ( !o->GetHiddenValue( V8STR_RO ).IsEmpty() ||
(o->HasNamedLookupInterceptor() && o->GetHiddenValue( V8STR_MODIFIED ).IsEmpty()) ) {
// object was readonly, use bson as is
return *originalBSON;
}
}
BSONObjBuilder b;