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
This commit is contained in:
Max Kellermann 2021-10-19 13:37:32 +02:00
parent 6120c1360c
commit fd5a3b5880
2 changed files with 6 additions and 1 deletions

1
NEWS
View File

@ -1,6 +1,7 @@
ver 0.23.2 (not yet released) ver 0.23.2 (not yet released)
* neighbor * neighbor
- mention failed plugin name in error message - mention failed plugin name in error message
* fix crash with libfmt versions older than 7
ver 0.23.1 (2021/10/19) ver 0.23.1 (2021/10/19)
* protocol * protocol

View File

@ -66,7 +66,11 @@ Response::WriteBinary(ConstBuffer<void> payload) noexcept
void void
Response::Error(enum ack code, const char *msg) noexcept 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 void