From 32b7b2e2fa1d2acbadea0390b63872451591ff5b Mon Sep 17 00:00:00 2001
From: Max Kellermann <mk@cm4all.com>
Date: Thu, 14 Jan 2021 13:02:30 +0100
Subject: [PATCH] util/AllocatedString: add default constructor

---
 src/lib/icu/Collate.cxx                  | 2 +-
 src/output/plugins/httpd/HttpdClient.cxx | 2 +-
 src/util/AllocatedString.hxx             | 4 +++-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/lib/icu/Collate.cxx b/src/lib/icu/Collate.cxx
index c31f46883..54d226895 100644
--- a/src/lib/icu/Collate.cxx
+++ b/src/lib/icu/Collate.cxx
@@ -88,7 +88,7 @@ IcuCollate(std::string_view a, std::string_view b) noexcept
 				     b.data(), b.size(), &code);
 
 #elif defined(_WIN32)
-	BasicAllocatedString<wchar_t> wa = nullptr, wb = nullptr;
+	BasicAllocatedString<wchar_t> wa, wb;
 
 	try {
 		wa = MultiByteToWideChar(CP_UTF8, a);
diff --git a/src/output/plugins/httpd/HttpdClient.cxx b/src/output/plugins/httpd/HttpdClient.cxx
index 36e9b3abc..8a88b131d 100644
--- a/src/output/plugins/httpd/HttpdClient.cxx
+++ b/src/output/plugins/httpd/HttpdClient.cxx
@@ -136,7 +136,7 @@ bool
 HttpdClient::SendResponse() noexcept
 {
 	char buffer[1024];
-	AllocatedString allocated = nullptr;
+	AllocatedString allocated;
 	const char *response;
 
 	assert(state == State::RESPONSE);
diff --git a/src/util/AllocatedString.hxx b/src/util/AllocatedString.hxx
index 3c9a7b9b9..2a5aaa02d 100644
--- a/src/util/AllocatedString.hxx
+++ b/src/util/AllocatedString.hxx
@@ -55,12 +55,13 @@ public:
 	static constexpr value_type SENTINEL = '\0';
 
 private:
-	pointer value;
+	pointer value = nullptr;
 
 	explicit BasicAllocatedString(pointer _value) noexcept
 		:value(_value) {}
 
 public:
+	BasicAllocatedString() noexcept = default;
 	BasicAllocatedString(std::nullptr_t n) noexcept
 		:value(n) {}
 
@@ -145,6 +146,7 @@ class AllocatedString : public BasicAllocatedString<char> {
 public:
 	using BasicAllocatedString::BasicAllocatedString;
 
+	AllocatedString() noexcept = default;
 	AllocatedString(BasicAllocatedString<value_type> &&src) noexcept
 		:BasicAllocatedString(std::move(src)) {}
 };