Cubase exploit/crash

VST SDK 3.7, Cubase 10 and 11

Description: Midi turns nuts (in this case Aftertouch is mapped to automation parameter 0) and and Cubase crashes on scanning plugins. It does not appear in other hosts.

Solution for the Cubase developers: The result of ‘id’ should only be copied to somewhere if the function really returns true.

Cubase can’t handle this code - do not use this:

tresult PLUGIN_API T2Audio::getMidiControllerAssignment(int32 busIndex, int16 channel,CtrlNumber midiControllerNumber,ParamID& id )
{
id = 0;//Causes Crash of Cubase 10 and 11; furthermore Midi goes nuts
switch (midiControllerNumber)
{
case kPitchBend: id = kPitchWheel; break;
case kCtrlModWheel: id = kModWheel; break;
}
return id != 0 ? kResultTrue : kResultFalse;
}

Fix for the plugin developer:

tresult PLUGIN_API T2Audio::getMidiControllerAssignment(int32 busIndex, int16 channel,CtrlNumber midiControllerNumber,ParamID& id )
{
if (midiControllerNumber == kPitchBend) { id = kPitchWheel; return kResultTrue; }
if (midiControllerNumber == kCtrlModWheel) { id = kModWheel; return kResultTrue; }
return kResultFalse;
}