Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UB in VST plugins due to function prototype mismatch #1478

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ class JuceVSTWrapper final : public AudioProcessorListener,

memset (&vstEffect, 0, sizeof (vstEffect));
vstEffect.magic = 0x56737450 /* 'VstP' */;
vstEffect.dispatcher = (Vst2::AEffectDispatcherProc) dispatcherCB;
vstEffect.dispatcher = dispatcherCB;
vstEffect.process = nullptr;
vstEffect.setParameter = (Vst2::AEffectSetParameterProc) setParameterCB;
vstEffect.getParameter = (Vst2::AEffectGetParameterProc) getParameterCB;
vstEffect.setParameter = setParameterCB;
vstEffect.getParameter = getParameterCB;
vstEffect.numPrograms = jmax (1, processor->getNumPrograms());
vstEffect.numParams = juceParameters.getNumParameters();
vstEffect.numInputs = maxNumInChannels;
Expand All @@ -292,8 +292,8 @@ class JuceVSTWrapper final : public AudioProcessorListener,
vstEffect.version = JucePlugin_VersionCode;
#endif

vstEffect.processReplacing = (Vst2::AEffectProcessProc) processReplacingCB;
vstEffect.processDoubleReplacing = (Vst2::AEffectProcessDoubleProc) processDoubleReplacingCB;
vstEffect.processReplacing = processReplacingCB;
vstEffect.processDoubleReplacing = processDoubleReplacingCB;

vstEffect.flags |= Vst2::effFlagsHasEditor;

Expand Down Expand Up @@ -505,7 +505,7 @@ class JuceVSTWrapper final : public AudioProcessorListener,
internalProcessReplacing (inputs, outputs, sampleFrames, floatTempBuffers);
}

static void processReplacingCB (Vst2::AEffect* vstInterface, float** inputs, float** outputs, int32 sampleFrames)
static void processReplacingCB (Vst2::AEffect* vstInterface, float** inputs, float** outputs, Vst2::VstInt32 sampleFrames)
{
getWrapper (vstInterface)->processReplacing (inputs, outputs, sampleFrames);
}
Expand All @@ -516,7 +516,7 @@ class JuceVSTWrapper final : public AudioProcessorListener,
internalProcessReplacing (inputs, outputs, sampleFrames, doubleTempBuffers);
}

static void processDoubleReplacingCB (Vst2::AEffect* vstInterface, double** inputs, double** outputs, int32 sampleFrames)
static void processDoubleReplacingCB (Vst2::AEffect* vstInterface, double** inputs, double** outputs, Vst2::VstInt32 sampleFrames)
{
getWrapper (vstInterface)->processDoubleReplacing (inputs, outputs, sampleFrames);
}
Expand Down Expand Up @@ -678,7 +678,7 @@ class JuceVSTWrapper final : public AudioProcessorListener,
return 0.0f;
}

static float getParameterCB (Vst2::AEffect* vstInterface, int32 index)
static float getParameterCB (Vst2::AEffect* vstInterface, Vst2::VstInt32 index)
{
return getWrapper (vstInterface)->getParameter (index);
}
Expand All @@ -689,7 +689,7 @@ class JuceVSTWrapper final : public AudioProcessorListener,
setValueAndNotifyIfChanged (*param, value);
}

static void setParameterCB (Vst2::AEffect* vstInterface, int32 index, float value)
static void setParameterCB (Vst2::AEffect* vstInterface, Vst2::VstInt32 index, float value)
{
getWrapper (vstInterface)->setParameter (index, value);
}
Expand Down Expand Up @@ -902,8 +902,8 @@ class JuceVSTWrapper final : public AudioProcessorListener,
}
}

static pointer_sized_int dispatcherCB (Vst2::AEffect* vstInterface, int32 opCode, int32 index,
pointer_sized_int value, void* ptr, float opt)
static Vst2::VstIntPtr dispatcherCB (Vst2::AEffect* vstInterface, Vst2::VstInt32 opCode, Vst2::VstInt32 index,
Vst2::VstIntPtr value, void* ptr, float opt)
{
auto* wrapper = getWrapper (vstInterface);
VstOpCodeArguments args = { index, value, ptr, opt };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ namespace

//==============================================================================
typedef Vst2::AEffect* (VSTCALLBACK *MainCall) (Vst2::audioMasterCallback);
static pointer_sized_int VSTCALLBACK audioMaster (Vst2::AEffect*, int32, int32, pointer_sized_int, void*, float);
static Vst2::VstIntPtr VSTCALLBACK audioMaster (Vst2::AEffect*, Vst2::VstInt32, Vst2::VstInt32, Vst2::VstIntPtr, void*, float);

//==============================================================================
// Change this to disable logging of various VST activities
Expand Down Expand Up @@ -3458,7 +3458,7 @@ bool VSTPluginInstance::updateSizeFromEditor ([[maybe_unused]] int w, [[maybe_un

//==============================================================================
// entry point for all callbacks from the plugin
static pointer_sized_int VSTCALLBACK audioMaster (Vst2::AEffect* effect, int32 opcode, int32 index, pointer_sized_int value, void* ptr, float opt)
static Vst2::VstIntPtr VSTCALLBACK audioMaster (Vst2::AEffect* effect, Vst2::VstInt32 opcode, Vst2::VstInt32 index, Vst2::VstIntPtr value, void* ptr, float opt)
{
if (effect != nullptr)
if (auto* instance = (VSTPluginInstance*) (effect->resvd2))
Expand Down