Browse Source

Add safety checks around CV control ranges

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.1-rc1
falkTX 4 years ago
parent
commit
cfdb181f37
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
1 changed files with 18 additions and 3 deletions
  1. +18
    -3
      source/backend/plugin/CarlaPlugin.cpp

+ 18
- 3
source/backend/plugin/CarlaPlugin.cpp View File

@@ -1736,11 +1736,10 @@ void CarlaPlugin::setParameterMappedControlIndex(const uint32_t parameterId, con
if (paramData.mappedControlIndex == index)
return;

const ParameterRanges& paramRanges(pData->param.ranges[parameterId]);

if ((paramData.hints & PARAMETER_MAPPED_RANGES_SET) == 0x0)
{
ParameterRanges& paramRanges(pData->param.ranges[parameterId]);
setParameterMappedRange(parameterId, paramRanges.min, paramRanges.max, true, true);
}

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
char strBuf[STR_MAX+1];
@@ -1770,6 +1769,15 @@ void CarlaPlugin::setParameterMappedControlIndex(const uint32_t parameterId, con
CARLA_SAFE_ASSERT(pData->client->removePort(kEnginePortTypeCV, strBuf, true));
CARLA_SAFE_ASSERT(pData->event.cvSourcePorts->removeCVSource(parameterId));
}
else if (paramData.mappedControlIndex == CONTROL_INDEX_NONE)
{
// when doing MIDI CC mapping, ensure ranges are within bounds
if (paramData.mappedMinimum < paramRanges.min || paramData.mappedMaximum > paramRanges.max)
setParameterMappedRange(parameterId,
std::max(paramData.mappedMinimum, paramRanges.min),
std::min(paramData.mappedMaximum, paramRanges.max),
true, true);
}
#endif

paramData.mappedControlIndex = index;
@@ -1800,6 +1808,13 @@ void CarlaPlugin::setParameterMappedRange(const uint32_t parameterId, const floa
(paramData.hints & PARAMETER_MAPPED_RANGES_SET) != 0x0)
return;

if (paramData.mappedControlIndex != CONTROL_INDEX_NONE && paramData.mappedControlIndex != CONTROL_INDEX_CV)
{
const ParameterRanges& paramRanges(pData->param.ranges[parameterId]);
CARLA_SAFE_ASSERT_RETURN(minimum >= paramRanges.min,);
CARLA_SAFE_ASSERT_RETURN(maximum <= paramRanges.max,);
}

paramData.hints |= PARAMETER_MAPPED_RANGES_SET;
paramData.mappedMinimum = minimum;
paramData.mappedMaximum = maximum;


Loading…
Cancel
Save