From 35b75e22856b708b300dd60516a4eb8d554e7d81 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Sat, 10 Aug 2024 09:59:32 +0200 Subject: [PATCH] fix: accidental handle copying in a range loop (#43282) fix: accidental handle copying Xref: https://github.com/electron/electron/pull/37857 Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> 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 a81360b0f1d..a607349cbb4 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() {