Skip to content

Commit

Permalink
Use rtc::ToString instead of std::to_string in `SocketAddress::Po…
Browse files Browse the repository at this point in the history
…rtAsString()` (#156)

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.
  • Loading branch information
mgsloan authored Dec 3, 2024
1 parent 543121b commit b99fd2c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rtc_base/socket_address.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b99fd2c

Please sign in to comment.