diff --git a/src/output/plugins/httpd/HttpdOutputPlugin.cxx b/src/output/plugins/httpd/HttpdOutputPlugin.cxx index ed35c1934..fa88bdda3 100644 --- a/src/output/plugins/httpd/HttpdOutputPlugin.cxx +++ b/src/output/plugins/httpd/HttpdOutputPlugin.cxx @@ -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));