output/httpd: copy from returned encoder buffer

This fixes a regression from commits c266fb7758 and 00b8ced09f,
but really caused by API change in commit 7e14f8f830, and this
plugin's failure to adapt to this API change.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1585
This commit is contained in:
Max Kellermann 2022-08-08 19:20:52 +02:00
parent 4c08c0b8b1
commit 2afe427ab3

View File

@ -161,12 +161,21 @@ HttpdOutput::ReadPage() noexcept
size_t size = 0;
do {
const auto r = encoder->Read(std::span{buffer}.subspan(size));
const auto b = std::span{buffer}.subspan(size);
const auto r = encoder->Read(b);
if (r.empty())
break;
unflushed_input = 0;
if (r.data() != b.data()) {
/* if the encoder did not write to the given
buffer but instead returned its own buffer,
we need to copy it so we have a contiguous
buffer */
std::copy(r.begin(), r.end(), b.begin());
}
size += r.size();
} while (size < sizeof(buffer));