Fix assertion failure when reading end of stream

Getting the address of the end of a vector apparently raises an
assertion failure now, even if we didn't do anything with it.
This commit is contained in:
Robbert van der Helm
2021-04-30 17:00:04 +02:00
parent 588a8fd590
commit 89d6c1b2e0
2 changed files with 8 additions and 4 deletions
+6 -4
View File
@@ -143,15 +143,17 @@ tresult PLUGIN_API YaBStream::read(void* buffer,
std::min(static_cast<int64_t>(numBytes),
static_cast<int64_t>(this->buffer.size()) - seek_position);
std::copy_n(&this->buffer[seek_position], bytes_to_read,
reinterpret_cast<uint8_t*>(buffer));
if (bytes_to_read > 0) {
std::copy_n(&this->buffer[seek_position], bytes_to_read,
reinterpret_cast<uint8_t*>(buffer));
seek_position += bytes_to_read;
}
seek_position += bytes_to_read;
if (numBytesRead) {
*numBytesRead = static_cast<int32>(bytes_to_read);
}
return Steinberg::kResultOk;
return bytes_to_read > 0 ? Steinberg::kResultOk : Steinberg::kResultFalse;
}
tresult PLUGIN_API YaBStream::write(void* buffer,