diff options
author | Max Kellermann <max@duempel.org> | 2014-06-17 02:45:43 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-06-17 03:21:11 +0200 |
commit | 966c4244cbe0de174df1e72e917078269ec9dbb9 (patch) | |
tree | 984f3bdb54010b5a7c35be4ed403565f6c46cc5b /src/input | |
parent | 81283f8bcb4ef3ab7c05944c38e3a7f1184231dd (diff) | |
download | mpd-966c4244cbe0de174df1e72e917078269ec9dbb9.tar.gz mpd-966c4244cbe0de174df1e72e917078269ec9dbb9.tar.xz mpd-966c4244cbe0de174df1e72e917078269ec9dbb9.zip |
AsyncInputStream: fix assertion failure in AppendToBuffer()
Diffstat (limited to '')
-rw-r--r-- | src/input/AsyncInputStream.cxx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/input/AsyncInputStream.cxx b/src/input/AsyncInputStream.cxx index 43190f907..9b827463d 100644 --- a/src/input/AsyncInputStream.cxx +++ b/src/input/AsyncInputStream.cxx @@ -222,11 +222,13 @@ AsyncInputStream::AppendToBuffer(const void *data, size_t append_size) const size_t remaining = append_size - nbytes; if (remaining > 0) { w = buffer.Write(); - assert(!w.IsEmpty()); - assert(w.size >= remaining); - memcpy(w.data, (const uint8_t *)data + nbytes, remaining); - buffer.Append(remaining); + if (!w.IsEmpty()) { + size_t nbytes2 = std::min(w.size, remaining); + memcpy(w.data, (const uint8_t *)data + nbytes, + nbytes2); + buffer.Append(nbytes2); + } } if (!IsReady()) |