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();
|
return info_->This();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsConstructCall() const {
|
||||||
|
return info_->IsConstructCall();
|
||||||
|
}
|
||||||
|
|
||||||
int Length() const {
|
int Length() const {
|
||||||
return info_->Length();
|
return info_->Length();
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,6 +151,11 @@ class Constructor {
|
||||||
private:
|
private:
|
||||||
static MATE_METHOD_RETURN_TYPE New(const WrappableFactoryFunction& factory,
|
static MATE_METHOD_RETURN_TYPE New(const WrappableFactoryFunction& factory,
|
||||||
v8::Isolate* isolate, Arguments* args) {
|
v8::Isolate* isolate, Arguments* args) {
|
||||||
|
if (!args->IsConstructCall()) {
|
||||||
|
args->ThrowError("Requires constructor call");
|
||||||
|
MATE_METHOD_RETURN_UNDEFINED();
|
||||||
|
}
|
||||||
|
|
||||||
Wrappable* object = internal::InvokeFactory(args, factory);
|
Wrappable* object = internal::InvokeFactory(args, factory);
|
||||||
if (object)
|
if (object)
|
||||||
object->Wrap(isolate, args->GetThis());
|
object->Wrap(isolate, args->GetThis());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue