diff options
author | ExE Boss <3889017+ExE-Boss@users.noreply.github.com> | 2020-12-17 14:10:00 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-12-22 16:13:56 +0300 |
commit | d90fa196c5540109bf9c5063f8c51673340ad9e3 (patch) | |
tree | 2a01a716c6fe0a36c537b140c7447fa276cb6740 /src/node_serdes.cc | |
parent | 656ce920a33272dbf24c5a5beccf57f637e7e832 (diff) |
v8: fix native `serdes` constructors
Fixes: https://github.com/nodejs/node/issues/13326
Refs: https://github.com/nodejs/node/pull/13541
PR-URL: https://github.com/nodejs/node/pull/36549
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'src/node_serdes.cc')
-rw-r--r-- | src/node_serdes.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/node_serdes.cc b/src/node_serdes.cc index 28844f1858f..b51d315989c 100644 --- a/src/node_serdes.cc +++ b/src/node_serdes.cc @@ -169,6 +169,10 @@ Maybe<bool> SerializerContext::WriteHostObject(Isolate* isolate, void SerializerContext::New(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); + if (!args.IsConstructCall()) { + return THROW_ERR_CONSTRUCT_CALL_REQUIRED( + env, "Class constructor Serializer cannot be invoked without 'new'"); + } new SerializerContext(env, args.This()); } @@ -319,6 +323,10 @@ MaybeLocal<Object> DeserializerContext::ReadHostObject(Isolate* isolate) { void DeserializerContext::New(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); + if (!args.IsConstructCall()) { + return THROW_ERR_CONSTRUCT_CALL_REQUIRED( + env, "Class constructor Deserializer cannot be invoked without 'new'"); + } if (!args[0]->IsArrayBufferView()) { return node::THROW_ERR_INVALID_ARG_TYPE( @@ -470,6 +478,7 @@ void Initialize(Local<Object> target, Local<String> serializerString = FIXED_ONE_BYTE_STRING(env->isolate(), "Serializer"); ser->SetClassName(serializerString); + ser->ReadOnlyPrototype(); target->Set(env->context(), serializerString, ser->GetFunction(env->context()).ToLocalChecked()).Check(); @@ -496,6 +505,8 @@ void Initialize(Local<Object> target, Local<String> deserializerString = FIXED_ONE_BYTE_STRING(env->isolate(), "Deserializer"); + des->SetLength(1); + des->ReadOnlyPrototype(); des->SetClassName(deserializerString); target->Set(env->context(), deserializerString, |