mirror of
https://github.com/electron/electron.git
synced 2026-02-16 01:56:59 -05:00
Guard against non-constructor call in Constructor::New
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user