fix: accidental handle copying in a range loop (#43281)

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 <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2024-08-10 09:59:36 +02:00 committed by GitHub
parent a780a75dec
commit c3a7f0001c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,6 +9,7 @@
#include <utility> #include <utility>
#include "base/containers/contains.h" #include "base/containers/contains.h"
#include "base/containers/to_vector.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/task/single_thread_task_runner.h" #include "base/task/single_thread_task_runner.h"
#include "gin/arguments.h" #include "gin/arguments.h"
@ -242,11 +243,7 @@ std::vector<blink::MessagePortChannel> MessagePort::DisentanglePorts(
} }
// Passed-in ports passed validity checks, so we can disentangle them. // Passed-in ports passed validity checks, so we can disentangle them.
std::vector<blink::MessagePortChannel> channels; return base::ToVector(ports, [](auto& port) { return port->Disentangle(); });
channels.reserve(ports.size());
for (auto port : ports)
channels.push_back(port->Disentangle());
return channels;
} }
void MessagePort::Pin() { void MessagePort::Pin() {