From f3470d3cd45e39066e4b048b5d036e7996713c74 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 30 Mar 2020 16:49:24 +0100 Subject: [PATCH] VST: Fixed potential out-of-bounds program access --- .../format_types/juce_VST3PluginFormat.cpp | 11 +++++++++-- .../format_types/juce_VSTPluginFormat.cpp | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 8f6591080a..2bd02a8c2d 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -2229,10 +2229,17 @@ public: //============================================================================== int getNumPrograms() override { return programNames.size(); } - const String getProgramName (int index) override { return programNames[index]; } - int getCurrentProgram() override { return jmax (0, roundToInt (editController->getParamNormalized (programParameterID) * (programNames.size() - 1))); } + const String getProgramName (int index) override { return index >= 0 ? programNames[index] : String(); } void changeProgramName (int, const String&) override {} + int getCurrentProgram() override + { + if (programNames.size() > 0 && editController != nullptr) + return jmax (0, roundToInt (editController->getParamNormalized (programParameterID) * (programNames.size() - 1))); + + return 0; + } + void setCurrentProgram (int program) override { if (programNames.size() > 0 && editController != nullptr) diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index f09a5c4a38..41e86aadf2 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -1596,7 +1596,7 @@ struct VSTPluginInstance : public AudioPluginInstance, } } - return programNames [index]; + return {}; } void changeProgramName (int index, const String& newName) override