diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-04-09 19:44:28 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2020-04-28 14:14:59 +0300 |
commit | b80b08fe35c9032bc2939f2e07c71fd1e5daa6f1 (patch) | |
tree | cb8f42effa74a71c3df270ebdbe7094e3accf3c9 /src/node_messaging.cc | |
parent | fd4320c49f0731ab8742cd2dbe871f20a7037ebb (diff) |
worker: fix type check in receiveMessageOnPort
Use the same type check we use in `MoveToContext()` in
`ReceiveMessage()`.
Fixes: https://github.com/nodejs/node/issues/32742
PR-URL: https://github.com/nodejs/node/pull/32745
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Diffstat (limited to 'src/node_messaging.cc')
-rw-r--r-- | src/node_messaging.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 657b409627c..28e31bbbb9b 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -867,7 +867,12 @@ void MessagePort::Drain(const FunctionCallbackInfo<Value>& args) { } void MessagePort::ReceiveMessage(const FunctionCallbackInfo<Value>& args) { - CHECK(args[0]->IsObject()); + Environment* env = Environment::GetCurrent(args); + if (!args[0]->IsObject() || + !env->message_port_constructor_template()->HasInstance(args[0])) { + return THROW_ERR_INVALID_ARG_TYPE(env, + "First argument needs to be a MessagePort instance"); + } MessagePort* port = Unwrap<MessagePort>(args[0].As<Object>()); if (port == nullptr) { // Return 'no messages' for a closed port. |