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