fix Object.bsonsize with null param SERVER-1753

This commit is contained in:
Eliot Horowitz
2010-09-07 23:02:02 -04:00
parent f4fd753e08
commit 296ddbb6b8
3 changed files with 18 additions and 6 deletions

View File

@@ -959,10 +959,16 @@ namespace mongo {
JS_ReportError( cx , "bsonsize requires one valid object" );
return JS_FALSE;
}
JSObject * o = JSVAL_TO_OBJECT( argv[0] );
Convertor c(cx);
if ( argv[0] == JSVAL_VOID || argv[0] == JSVAL_NULL ){
*rval = c.toval( 0.0 );
return JS_TRUE;
}
JSObject * o = JSVAL_TO_OBJECT( argv[0] );
double size = 0;
if ( JS_InstanceOf( cx , o , &bson_ro_class , 0 ) ||