Browse Source

Fixed a crash when loading/restoring a VST3's plug-in state in Cubase 9

tags/2021-05-28
hogliux 8 years ago
parent
commit
d496a77462
1 changed files with 22 additions and 6 deletions
  1. +22
    -6
      modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp

+ 22
- 6
modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp View File

@@ -1365,19 +1365,35 @@ public:
bool readFromMemoryStream (IBStream* state)
{
FUnknownPtr<MemoryStream> s (state);
FUnknownPtr<ISizeableStream> s (state);
Steinberg::int64 size = 0;
if (s != nullptr
&& s->getData() != nullptr
&& s->getSize() > 0
&& s->getSize() < 1024 * 1024 * 100) // (some hosts seem to return junk for the size)
&& s->getStreamSize (size) == kResultOk
&& size > 0
&& size < 1024 * 1024 * 100) // (some hosts seem to return junk for the size)
{
MemoryBlock block (static_cast<size_t> (size));
// turns out that Cubase 9 might give you the incorrect stream size :-(
Steinberg::int32 bytesRead = 1;
int len;
for (len = 0; bytesRead > 0 && len < static_cast<int> (block.getSize()); len += bytesRead)
if (state->read (block.getData(), static_cast<int32> (block.getSize()), &bytesRead) != kResultOk)
break;
if (len == 0)
return false;
block.setSize (static_cast<size_t> (len));
// Adobe Audition CS6 hack to avoid trying to use corrupted streams:
if (getHostType().isAdobeAudition())
if (s->getSize() >= 5 && memcmp (s->getData(), "VC2!E", 5) == 0)
if (block.getSize() >= 5 && memcmp (block.getData(), "VC2!E", 5) == 0)
return false;
return loadStateData (s->getData(), (int) s->getSize());
return loadStateData (block.getData(), (int) block.getSize());
}
return false;


Loading…
Cancel
Save