From 201375e4a51f633467ce1c8185a7510ca0bd9af5 Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Wed, 6 Mar 2019 15:06:44 +0000 Subject: [PATCH] VST3: Allow loading non-JUCE plug-in state when JUCE_VST3_CAN_REPLACE_VST2 is set --- .../VST3/juce_VST3_Wrapper.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index 742659faa9..8f98e7cc58 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -1695,14 +1695,13 @@ public: } #endif - bool loadStateData (const void* data, int size) + void loadStateData (const void* data, int size) { #if JUCE_VST3_CAN_REPLACE_VST2 - return loadVST2CompatibleState ((const char*) data, size); - #else - setStateInformation (data, size); - return true; + if (loadVST2CompatibleState ((const char*) data, size)) + return; #endif + setStateInformation (data, size); } bool readFromMemoryStream (IBStream* state) @@ -1735,7 +1734,8 @@ public: if (block.getSize() >= 5 && memcmp (block.getData(), "VC2!E", 5) == 0) return false; - return loadStateData (block.getData(), (int) block.getSize()); + loadStateData (block.getData(), (int) block.getSize()); + return true; } return false; @@ -1763,8 +1763,11 @@ public: const size_t dataSize = allData.getDataSize(); - return dataSize > 0 && dataSize < 0x7fffffff - && loadStateData (allData.getData(), (int) dataSize); + if (dataSize <= 0 || dataSize >= 0x7fffffff) + return false; + + loadStateData (allData.getData(), (int) dataSize); + return true; } tresult PLUGIN_API setState (IBStream* state) override