Skip to content

Commit fdfe4b7

Browse files
Fix UB in VST plugins due to function prototype mismatch
1 parent 5737c42 commit fdfe4b7

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,10 @@ class JuceVSTWrapper final : public AudioProcessorListener,
274274

275275
memset (&vstEffect, 0, sizeof (vstEffect));
276276
vstEffect.magic = 0x56737450 /* 'VstP' */;
277-
vstEffect.dispatcher = (Vst2::AEffectDispatcherProc) dispatcherCB;
277+
vstEffect.dispatcher = dispatcherCB;
278278
vstEffect.process = nullptr;
279-
vstEffect.setParameter = (Vst2::AEffectSetParameterProc) setParameterCB;
280-
vstEffect.getParameter = (Vst2::AEffectGetParameterProc) getParameterCB;
279+
vstEffect.setParameter = setParameterCB;
280+
vstEffect.getParameter = getParameterCB;
281281
vstEffect.numPrograms = jmax (1, processor->getNumPrograms());
282282
vstEffect.numParams = juceParameters.getNumParameters();
283283
vstEffect.numInputs = maxNumInChannels;
@@ -292,8 +292,8 @@ class JuceVSTWrapper final : public AudioProcessorListener,
292292
vstEffect.version = JucePlugin_VersionCode;
293293
#endif
294294

295-
vstEffect.processReplacing = (Vst2::AEffectProcessProc) processReplacingCB;
296-
vstEffect.processDoubleReplacing = (Vst2::AEffectProcessDoubleProc) processDoubleReplacingCB;
295+
vstEffect.processReplacing = processReplacingCB;
296+
vstEffect.processDoubleReplacing = processDoubleReplacingCB;
297297

298298
vstEffect.flags |= Vst2::effFlagsHasEditor;
299299

@@ -505,7 +505,7 @@ class JuceVSTWrapper final : public AudioProcessorListener,
505505
internalProcessReplacing (inputs, outputs, sampleFrames, floatTempBuffers);
506506
}
507507

508-
static void processReplacingCB (Vst2::AEffect* vstInterface, float** inputs, float** outputs, int32 sampleFrames)
508+
static void processReplacingCB (Vst2::AEffect* vstInterface, float** inputs, float** outputs, Vst2::VstInt32 sampleFrames)
509509
{
510510
getWrapper (vstInterface)->processReplacing (inputs, outputs, sampleFrames);
511511
}
@@ -516,7 +516,7 @@ class JuceVSTWrapper final : public AudioProcessorListener,
516516
internalProcessReplacing (inputs, outputs, sampleFrames, doubleTempBuffers);
517517
}
518518

519-
static void processDoubleReplacingCB (Vst2::AEffect* vstInterface, double** inputs, double** outputs, int32 sampleFrames)
519+
static void processDoubleReplacingCB (Vst2::AEffect* vstInterface, double** inputs, double** outputs, Vst2::VstInt32 sampleFrames)
520520
{
521521
getWrapper (vstInterface)->processDoubleReplacing (inputs, outputs, sampleFrames);
522522
}
@@ -678,7 +678,7 @@ class JuceVSTWrapper final : public AudioProcessorListener,
678678
return 0.0f;
679679
}
680680

681-
static float getParameterCB (Vst2::AEffect* vstInterface, int32 index)
681+
static float getParameterCB (Vst2::AEffect* vstInterface, Vst2::VstInt32 index)
682682
{
683683
return getWrapper (vstInterface)->getParameter (index);
684684
}
@@ -689,7 +689,7 @@ class JuceVSTWrapper final : public AudioProcessorListener,
689689
setValueAndNotifyIfChanged (*param, value);
690690
}
691691

692-
static void setParameterCB (Vst2::AEffect* vstInterface, int32 index, float value)
692+
static void setParameterCB (Vst2::AEffect* vstInterface, Vst2::VstInt32 index, float value)
693693
{
694694
getWrapper (vstInterface)->setParameter (index, value);
695695
}
@@ -902,8 +902,8 @@ class JuceVSTWrapper final : public AudioProcessorListener,
902902
}
903903
}
904904

905-
static pointer_sized_int dispatcherCB (Vst2::AEffect* vstInterface, int32 opCode, int32 index,
906-
pointer_sized_int value, void* ptr, float opt)
905+
static Vst2::VstIntPtr dispatcherCB (Vst2::AEffect* vstInterface, Vst2::VstInt32 opCode, Vst2::VstInt32 index,
906+
Vst2::VstIntPtr value, void* ptr, float opt)
907907
{
908908
auto* wrapper = getWrapper (vstInterface);
909909
VstOpCodeArguments args = { index, value, ptr, opt };

modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ namespace
223223

224224
//==============================================================================
225225
typedef Vst2::AEffect* (VSTCALLBACK *MainCall) (Vst2::audioMasterCallback);
226-
static pointer_sized_int VSTCALLBACK audioMaster (Vst2::AEffect*, int32, int32, pointer_sized_int, void*, float);
226+
static Vst2::VstIntPtr VSTCALLBACK audioMaster (Vst2::AEffect*, Vst2::VstInt32, Vst2::VstInt32, Vst2::VstIntPtr, void*, float);
227227

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

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

0 commit comments

Comments
 (0)