From 7ec53bddcd194fbb9a62e9ad53e21012c0e6f1fe Mon Sep 17 00:00:00 2001 From: "mgsloan@gmail.com" Date: Tue, 26 Nov 2024 15:29:03 -0700 Subject: [PATCH] Use `rtc::ToString` instead of `std::to_string` in `SocketAddress::PortAsString()` Justification for this change is that `std::to_string` should be avoided as it uses the user's locale and calls to it get serialized, which is bad for concurrency. My actual motivation for this is quite bizarre. Before this change, with Zed's use of the LiveKit Rust SDK, I was getting connection strings that were not valid utf-8, instead having a port of `3\u0000\u0000\u001c\u0000`. I have not figured out how that could happen or why this change fixes it. --- rtc_base/socket_address.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtc_base/socket_address.cc b/rtc_base/socket_address.cc index 8601fc9040..4fc19d5831 100644 --- a/rtc_base/socket_address.cc +++ b/rtc_base/socket_address.cc @@ -162,7 +162,7 @@ std::string SocketAddress::HostAsSensitiveURIString() const { } std::string SocketAddress::PortAsString() const { - return std::to_string(port_); + return rtc::ToString(port_); } std::string SocketAddress::ToString() const {