Skip to content

Commit

Permalink
fix potential crash on wrong comparator size (p2d, p3d)
Browse files Browse the repository at this point in the history
  • Loading branch information
benkuper committed Jun 10, 2024
1 parent 8c782b0 commit 0e28724
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ bool Point2DComparator::compareInternal(Parameter* sourceParam, int multiplexInd
Point<float> p = ((Point2DParameter*)sourceParam)->getPoint();
var value = isMultiplexed() ? refLink->getLinkedValue(multiplexIndex) : reference->getValue();

if (currentFunctionId == equalsId) return p == Point<float>(value[0], value[1]);
if (currentFunctionId == equalsId)
{
//jassert(value.size() >= 2);
if (value.size() < 2) return false;
return p == Point<float>(value[0], value[1]);
}
else if (currentFunctionId == magnGreaterId) return p.getDistanceFromOrigin() > (float)value;
else if (currentFunctionId == magnLessId) return p.getDistanceFromOrigin() < (float)value;
else if (currentFunctionId == xGreaterId) return p.x > (float)value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ bool Point3DComparator::compareInternal(Parameter* sourceParam, int multiplexInd
Vector3D<float> p = ((Point3DParameter*)sourceParam)->getVector();
var value = isMultiplexed() ? refLink->getLinkedValue(multiplexIndex) : reference->getValue();

if (currentFunctionId == equalsId) return p.x == (float)value[0] && p.y == (float)value[1] && p.z == (float)value[2];
if (currentFunctionId == equalsId)
{
if (value.size() < 3) return false;
return p.x == (float)value[0] && p.y == (float)value[1] && p.z == (float)value[2];
}
else if (currentFunctionId == magnGreaterId) return p.length() > (float)value;
else if (currentFunctionId == magnLessId) return p.length() < (float)value;
else if (currentFunctionId == xGreaterId) return p.x > (float)value;
Expand Down

0 comments on commit 0e28724

Please sign in to comment.