diff options
author | Mohammad Dashti <mdashti@gmail.com> | 2022-03-08 18:33:54 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-03-08 19:56:02 +0000 |
commit | 93d83ccc71b55982260d98eac0f8df7d4a57c905 (patch) | |
tree | f6142c87c8dfab507c6fd412cb357cd04aaf6fff /src/mongo/scripting | |
parent | 7a003039250c67c00b1db195a0d8fd8c3c770943 (diff) | |
download | mongo-93d83ccc71b55982260d98eac0f8df7d4a57c905.tar.gz |
SERVER-64298 Added some safety checks for failed JS constructor calls
Diffstat (limited to 'src/mongo/scripting')
-rw-r--r-- | src/mongo/scripting/mozjs/wraptype.h | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/mongo/scripting/mozjs/wraptype.h b/src/mongo/scripting/mozjs/wraptype.h index c1da664aec7..ee85a0e07e4 100644 --- a/src/mongo/scripting/mozjs/wraptype.h +++ b/src/mongo/scripting/mozjs/wraptype.h @@ -359,10 +359,7 @@ public: JS::ObjectValue(T::installType == InstallType::OverNative ? *_constructor : *_proto)); JS::RootedObject result(_context); - // TODO SERVER-61008 JS::Construct returns a boolean. What does it mean if it's 'false'? - JS::Construct(_context, fVal, args, &result); - - out.set(_assertPtr(result.get())); + out.set(_assertPtr(JS::Construct(_context, fVal, args, &result) ? result.get() : nullptr)); } void newInstance(JS::MutableHandleValue out) { @@ -380,10 +377,8 @@ public: JS::ObjectValue(T::installType == InstallType::OverNative ? *_constructor : *_proto)); JS::RootedObject result(_context); - // TODO SERVER-61008 JS::Construct returns a boolean. What does it mean if it's 'false'? - JS::Construct(_context, fVal, args, &result); - - out.setObjectOrNull(_assertPtr(result.get())); + out.setObjectOrNull( + _assertPtr(JS::Construct(_context, fVal, args, &result) ? result.get() : nullptr)); } // instanceOf doesn't go up the prototype tree. It's a lower level more specific match |