From f3d09b6e4f0bb53d624c26eef27fd2cc589312ff Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 23 Sep 2018 19:26:30 +0200 Subject: [PATCH] src: simplify `MessagePort` construction code a bit Using `ASSIGN_OR_RETURN_UNWRAP` would return if the created `MessagePort` object had no internal fields. That would be a bug, so switch to a checked conversion instead. PR-URL: https://github.com/nodejs/node/pull/23036 Reviewed-By: Gus Caplan Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Joyee Cheung --- src/node_messaging.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 20e0c7673b8fa9..bb7344503e72c5 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -483,14 +483,14 @@ MessagePort* MessagePort::New( Local ctor; if (!GetMessagePortConstructor(env, context).ToLocal(&ctor)) return nullptr; - MessagePort* port = nullptr; // Construct a new instance, then assign the listener instance and possibly // the MessagePortData to it. Local instance; if (!ctor->NewInstance(context).ToLocal(&instance)) return nullptr; - ASSIGN_OR_RETURN_UNWRAP(&port, instance, nullptr); + MessagePort* port = Unwrap(instance); + CHECK_NOT_NULL(port); if (data) { port->Detach(); port->data_ = std::move(data);