diff --git a/lldb/source/Host/posix/DomainSocket.cpp b/lldb/source/Host/posix/DomainSocket.cpp index 790458ee13d0..8138b6ff1dc4 100644 --- a/lldb/source/Host/posix/DomainSocket.cpp +++ b/lldb/source/Host/posix/DomainSocket.cpp @@ -143,8 +143,7 @@ std::string DomainSocket::GetSocketName() const { llvm::StringRef name(saddr_un.sun_path + GetNameOffset(), sock_addr_len - offsetof(struct sockaddr_un, sun_path) - GetNameOffset()); - if (name.back() == '\0') - name = name.drop_back(); + name = name.drop_while([](char c) { return c == '\0'; }); return name.str(); }