From 89d6c1b2e0cc9253c745dc73f7c152cbc426eb4f Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 30 Apr 2021 17:00:04 +0200 Subject: [PATCH] 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. --- CHANGELOG.md | 2 ++ src/common/serialization/vst3/bstream.cpp | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48002192..0cc3412f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). open. - Fixed a regression from yabridge 3.1.0 where REAPER would freeze when opening a VST3 plugin context menu. +- Fixed a potential assertion failure when setting VST3 preset data. This would + depend on the `libstdc++` version used to built yabridge with. - _PSPaudioware InifniStrip_ would fail to initialize because the plugin expects the host to always be using Microsoft COM and it won't initialize it by itself. InfiniStrip loads as expected now. diff --git a/src/common/serialization/vst3/bstream.cpp b/src/common/serialization/vst3/bstream.cpp index e48514c5..02dcdb3f 100644 --- a/src/common/serialization/vst3/bstream.cpp +++ b/src/common/serialization/vst3/bstream.cpp @@ -143,15 +143,17 @@ tresult PLUGIN_API YaBStream::read(void* buffer, std::min(static_cast(numBytes), static_cast(this->buffer.size()) - seek_position); - std::copy_n(&this->buffer[seek_position], bytes_to_read, - reinterpret_cast(buffer)); + if (bytes_to_read > 0) { + std::copy_n(&this->buffer[seek_position], bytes_to_read, + reinterpret_cast(buffer)); + seek_position += bytes_to_read; + } - seek_position += bytes_to_read; if (numBytesRead) { *numBytesRead = static_cast(bytes_to_read); } - return Steinberg::kResultOk; + return bytes_to_read > 0 ? Steinberg::kResultOk : Steinberg::kResultFalse; } tresult PLUGIN_API YaBStream::write(void* buffer,