From 47864dca6952e30fd8e6d1ccadf1e342a9734062 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Fri, 9 Aug 2024 18:38:14 +0000 Subject: [PATCH] fix: accidental handle copying Xref: https://github.com/electron/electron/pull/37857 Co-authored-by: Charles Kerr --- shell/browser/api/message_port.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/shell/browser/api/message_port.cc b/shell/browser/api/message_port.cc index a81360b0f1da0..a607349cbb4b7 100644 --- a/shell/browser/api/message_port.cc +++ b/shell/browser/api/message_port.cc @@ -9,6 +9,7 @@ #include #include "base/containers/contains.h" +#include "base/containers/to_vector.h" #include "base/strings/string_number_conversions.h" #include "base/task/single_thread_task_runner.h" #include "gin/arguments.h" @@ -242,11 +243,7 @@ std::vector MessagePort::DisentanglePorts( } // Passed-in ports passed validity checks, so we can disentangle them. - std::vector channels; - channels.reserve(ports.size()); - for (auto port : ports) - channels.push_back(port->Disentangle()); - return channels; + return base::ToVector(ports, [](auto& port) { return port->Disentangle(); }); } void MessagePort::Pin() {