Skip to content

Commit f3d09b6

Browse files
addaleaxtargos
authored andcommitted
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: #23036 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent 4d61c34 commit f3d09b6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/node_messaging.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,14 @@ MessagePort* MessagePort::New(
483483
Local<Function> ctor;
484484
if (!GetMessagePortConstructor(env, context).ToLocal(&ctor))
485485
return nullptr;
486-
MessagePort* port = nullptr;
487486

488487
// Construct a new instance, then assign the listener instance and possibly
489488
// the MessagePortData to it.
490489
Local<Object> instance;
491490
if (!ctor->NewInstance(context).ToLocal(&instance))
492491
return nullptr;
493-
ASSIGN_OR_RETURN_UNWRAP(&port, instance, nullptr);
492+
MessagePort* port = Unwrap<MessagePort>(instance);
493+
CHECK_NOT_NULL(port);
494494
if (data) {
495495
port->Detach();
496496
port->data_ = std::move(data);

0 commit comments

Comments
 (0)