some sm safety

This commit is contained in:
Eliot Horowitz
2009-08-28 16:35:09 -04:00
parent e061b7d9da
commit 46cbb8a6b2
2 changed files with 10 additions and 3 deletions

View File

@@ -772,6 +772,7 @@ namespace mongo {
Convertor c( cx );
BSONHolder * holder = GETHOLDER( cx , obj );
assert( holder );
holder->check();
string s = c.toString( id );
@@ -1090,11 +1091,15 @@ namespace mongo {
void setThis( const BSONObj * obj ){
smlock;
if ( _this )
if ( _this ){
JS_RemoveRoot( _context , &_this );
_this = 0;
}
_this = _convertor->toJSObject( obj );
JS_AddNamedRoot( _context , &_this , "scope this" );
if ( obj ){
_this = _convertor->toJSObject( obj );
JS_AddNamedRoot( _context , &_this , "scope this" );
}
}
// ---- functions -----