From fd5a3b5880a432a15097c1714da14b11d7bd2ed7 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Tue, 19 Oct 2021 13:37:32 +0200
Subject: [PATCH] client/Response: reimplement Error() without FmtError()

With libfmt versions older than 7, this leads to an endless recursion
between Error() and FmtError(), resulting in a crash due to stack
overflow.  D'oh!

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1295
---
 NEWS                    | 1 +
 src/client/Response.cxx | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 6b36ece15..0ec26e39f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 ver 0.23.2 (not yet released)
 * neighbor
   - mention failed plugin name in error message
+* fix crash with libfmt versions older than 7
 
 ver 0.23.1 (2021/10/19)
 * protocol
diff --git a/src/client/Response.cxx b/src/client/Response.cxx
index cda9e4969..4bfe10069 100644
--- a/src/client/Response.cxx
+++ b/src/client/Response.cxx
@@ -66,7 +66,11 @@ Response::WriteBinary(ConstBuffer<void> payload) noexcept
 void
 Response::Error(enum ack code, const char *msg) noexcept
 {
-	FmtError(code, FMT_STRING("{}"), msg);
+	Fmt(FMT_STRING("ACK [{}@{}] {{{}}} "),
+	    (int)code, list_index, command);
+
+	Write(msg);
+	Write("\n");
 }
 
 void