mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Fix uninitialized seek position in VectorStream
This commit is contained in:
@@ -193,7 +193,7 @@ VectorStream::VectorStream(Steinberg::IBStream* stream) {
|
||||
int64 size;
|
||||
assert(stream->tell(&size) == Steinberg::kResultOk);
|
||||
|
||||
int32 num_bytes_read;
|
||||
int32 num_bytes_read = 0;
|
||||
buffer.resize(size);
|
||||
assert(stream->seek(0, Steinberg::IBStream::IStreamSeekMode::kIBSeekSet) ==
|
||||
Steinberg::kResultOk);
|
||||
@@ -227,14 +227,12 @@ tresult VectorStream::write_back(Steinberg::IBStream* stream) const {
|
||||
return Steinberg::kInvalidArgument;
|
||||
}
|
||||
|
||||
int32 num_bytes_written;
|
||||
int32 num_bytes_written = 0;
|
||||
assert(stream->seek(0, kIBSeekSet) == Steinberg::kResultOk);
|
||||
// When writing zero bytes, some hosts will return `kResultFalse`
|
||||
if (stream->write(const_cast<uint8_t*>(buffer.data()), buffer.size(),
|
||||
&num_bytes_written) == Steinberg::kResultOk) {
|
||||
assert(num_bytes_written == 0 ||
|
||||
static_cast<size_t>(num_bytes_written) == buffer.size());
|
||||
}
|
||||
assert(stream->write(const_cast<uint8_t*>(buffer.data()), buffer.size(),
|
||||
&num_bytes_written) == Steinberg::kResultOk);
|
||||
assert(num_bytes_written == 0 ||
|
||||
static_cast<size_t>(num_bytes_written) == buffer.size());
|
||||
|
||||
return Steinberg::kResultOk;
|
||||
}
|
||||
@@ -276,7 +274,7 @@ tresult PLUGIN_API VectorStream::write(void* buffer,
|
||||
}
|
||||
|
||||
std::copy_n(reinterpret_cast<uint8_t*>(buffer), numBytes,
|
||||
&this->buffer[seek_position]);
|
||||
this->buffer.begin() + seek_position);
|
||||
|
||||
seek_position += numBytes;
|
||||
if (numBytesWritten) {
|
||||
|
||||
@@ -225,7 +225,7 @@ class VectorStream : public Steinberg::IBStream,
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> buffer;
|
||||
size_t seek_position;
|
||||
size_t seek_position = 0;
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
@@ -139,7 +139,7 @@ void Vst3Bridge::run() {
|
||||
},
|
||||
[&](Vst3PluginProxy::GetState& request)
|
||||
-> Vst3PluginProxy::GetState::Response {
|
||||
VectorStream stream;
|
||||
VectorStream stream{};
|
||||
tresult result;
|
||||
|
||||
// This same function is defined in both `IComponent` and
|
||||
@@ -288,6 +288,8 @@ void Vst3Bridge::run() {
|
||||
// and pass that to the initialize function. This object should
|
||||
// be cleaned up again during `Vst3PluginProxy::Destruct`.
|
||||
// TODO: This needs changing when we get to `Vst3HostProxy`
|
||||
// TODO: Does this have to be run from the UI thread? Figure out
|
||||
// if it does
|
||||
Steinberg::FUnknown* context = nullptr;
|
||||
if (request.host_application_context_args) {
|
||||
object_instances[request.instance_id]
|
||||
|
||||
Reference in New Issue
Block a user