From 5fd2fc77f31cc123ab37e36aaaee1bfa6971c414 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 18 Sep 2023 11:07:56 +0200 Subject: [PATCH] net/ToString: add null check --- src/net/ToString.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/net/ToString.cxx b/src/net/ToString.cxx index d4118ef40..db7d47daa 100644 --- a/src/net/ToString.cxx +++ b/src/net/ToString.cxx @@ -50,6 +50,9 @@ LocalAddressToString(std::string_view raw) noexcept std::string ToString(SocketAddress address) noexcept { + if (address.IsNull() || address.GetSize() == 0) + return "null"; + #ifdef HAVE_UN if (address.GetFamily() == AF_LOCAL) /* return path of local socket */ @@ -88,7 +91,7 @@ ToString(SocketAddress address) noexcept std::string HostToString(SocketAddress address) noexcept { - if (address.IsNull()) + if (address.IsNull() || address.GetSize() == 0) return "null"; #ifdef HAVE_UN