Catch negative indices in IParamValueQueue impl

This would cause crashes with the validator which created empty
parameter queues, and many plugins try to `getPoint(numPoints() - 1)`.
This commit is contained in:
Robbert van der Helm
2023-04-14 03:28:13 +02:00
parent e5a54637cd
commit 265ab1487b
3 changed files with 16 additions and 4 deletions
+8
View File
@@ -17,6 +17,14 @@ Versioning](https://semver.org/spec/v2.0.0.html).
makes sure that Wine will keep using X11 even if Wayland support becomes makes sure that Wine will keep using X11 even if Wayland support becomes
available at some point. available at some point.
### Fixed
- Negative indices were not treated as invalid arguments in some of the VST3
interface implementations and could cause crashes if a plugin for instance
tried to query a parameter value with signed index -1. This has now been
fixed. The issue only appeared with the VST3 validator, and not with any
regular hosts.
### yabridgectl ### yabridgectl
- VST 3.7.5 `moduleinfo.json` files without a `Compatibility` field are now - VST 3.7.5 `moduleinfo.json` files without a `Compatibility` field are now
@@ -71,7 +71,8 @@ tresult PLUGIN_API YaParamValueQueue::getPoint(
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters) // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
int32& sampleOffset /*out*/, int32& sampleOffset /*out*/,
Steinberg::Vst::ParamValue& value /*out*/) { Steinberg::Vst::ParamValue& value /*out*/) {
if (index < static_cast<int32>(queue_.size())) { // Indices are signed integers, fun
if (index >= 0 && index < static_cast<int32>(queue_.size())) {
sampleOffset = queue_[index].first; sampleOffset = queue_[index].first;
value = queue_[index].second; value = queue_[index].second;
@@ -118,7 +118,8 @@ int32 PLUGIN_API YaPluginFactory3::countClasses() {
tresult PLUGIN_API YaPluginFactory3::getClassInfo(Steinberg::int32 index, tresult PLUGIN_API YaPluginFactory3::getClassInfo(Steinberg::int32 index,
Steinberg::PClassInfo* info) { Steinberg::PClassInfo* info) {
if (index >= static_cast<int32>(arguments_.class_infos_1.size())) { if (index < 0 ||
index >= static_cast<int32>(arguments_.class_infos_1.size())) {
return Steinberg::kInvalidArgument; return Steinberg::kInvalidArgument;
} }
@@ -134,7 +135,8 @@ tresult PLUGIN_API YaPluginFactory3::getClassInfo(Steinberg::int32 index,
tresult PLUGIN_API tresult PLUGIN_API
YaPluginFactory3::getClassInfo2(int32 index, Steinberg::PClassInfo2* info) { YaPluginFactory3::getClassInfo2(int32 index, Steinberg::PClassInfo2* info) {
if (index >= static_cast<int32>(arguments_.class_infos_2.size())) { if (index < 0 ||
index >= static_cast<int32>(arguments_.class_infos_2.size())) {
return Steinberg::kInvalidArgument; return Steinberg::kInvalidArgument;
} }
@@ -151,7 +153,8 @@ YaPluginFactory3::getClassInfo2(int32 index, Steinberg::PClassInfo2* info) {
tresult PLUGIN_API tresult PLUGIN_API
YaPluginFactory3::getClassInfoUnicode(int32 index, YaPluginFactory3::getClassInfoUnicode(int32 index,
Steinberg::PClassInfoW* info) { Steinberg::PClassInfoW* info) {
if (index >= static_cast<int32>(arguments_.class_infos_unicode.size())) { if (index < 0 ||
index >= static_cast<int32>(arguments_.class_infos_unicode.size())) {
return Steinberg::kInvalidArgument; return Steinberg::kInvalidArgument;
} }