Guard against non-constructor call in Constructor::New
This commit is contained in:
parent
b1f7cfa9da
commit
4a1d11b2be
2 changed files with 9 additions and 0 deletions
|
@ -60,6 +60,10 @@ class Arguments {
|
|||
return info_->This();
|
||||
}
|
||||
|
||||
bool IsConstructCall() const {
|
||||
return info_->IsConstructCall();
|
||||
}
|
||||
|
||||
int Length() const {
|
||||
return info_->Length();
|
||||
}
|
||||
|
|
|
@ -151,6 +151,11 @@ class Constructor {
|
|||
private:
|
||||
static MATE_METHOD_RETURN_TYPE New(const WrappableFactoryFunction& factory,
|
||||
v8::Isolate* isolate, Arguments* args) {
|
||||
if (!args->IsConstructCall()) {
|
||||
args->ThrowError("Requires constructor call");
|
||||
MATE_METHOD_RETURN_UNDEFINED();
|
||||
}
|
||||
|
||||
Wrappable* object = internal::InvokeFactory(args, factory);
|
||||
if (object)
|
||||
object->Wrap(isolate, args->GetThis());
|
||||
|
|
Loading…
Reference in a new issue