Commit 966c4244 authored by Max Kellermann's avatar Max Kellermann

AsyncInputStream: fix assertion failure in AppendToBuffer()

parent 81283f8b
...@@ -222,11 +222,13 @@ AsyncInputStream::AppendToBuffer(const void *data, size_t append_size) ...@@ -222,11 +222,13 @@ AsyncInputStream::AppendToBuffer(const void *data, size_t append_size)
const size_t remaining = append_size - nbytes; const size_t remaining = append_size - nbytes;
if (remaining > 0) { if (remaining > 0) {
w = buffer.Write(); w = buffer.Write();
assert(!w.IsEmpty());
assert(w.size >= remaining);
memcpy(w.data, (const uint8_t *)data + nbytes, remaining); if (!w.IsEmpty()) {
buffer.Append(remaining); size_t nbytes2 = std::min(w.size, remaining);
memcpy(w.data, (const uint8_t *)data + nbytes,
nbytes2);
buffer.Append(nbytes2);
}
} }
if (!IsReady()) if (!IsReady())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment