Skip to content

Commit b050d02

Browse files
committed
BUG: Fix out-of-bounds array access in RequireMinNumNeighbors Filter
Signed-off-by: Michael Jackson <[email protected]>
1 parent 7ed7e81 commit b050d02

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/RequireMinNumNeighbors.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,23 @@ Result<> CopyTupleFromArray(DataStructure& dataStructure, const DataPath& dataAr
1717
auto arraySize = voxelArray->getSize();
1818
for(const auto& featureIdIndex : badFeatureIdIndexes)
1919
{
20-
int32 featureName = featureIds.getValue(featureIdIndex);
21-
int32 neighbor = neighbors[featureIdIndex];
20+
const int32 featureName = featureIds.getValue(featureIdIndex);
21+
const int32 neighbor = neighbors[featureIdIndex];
22+
2223
if((neighbor >= arraySize || featureIdIndex >= arraySize) && (featureName < 0 && neighbor >= 0 && featureIds.getValue(neighbor) >= 0))
2324
{
2425
const std::string message =
2526
fmt::format("Out of range: While trying to copy a tuple from index {} to index {}\n Array Name: {}\n Num. Tuples: {}", neighbor, featureIdIndex, dataArrayPath.toString(), arraySize);
2627
mesgHandler(nx::core::IFilter::Message{nx::core::IFilter::Message::Type::Info, message});
2728
return MakeErrorResult(-55568, message);
2829
}
29-
if(int32 fId = featureIds.getValue(neighbor); featureName < 0 && neighbor >= 0 && fId >= 0)
30+
31+
if(featureName < 0 && neighbor >= 0)
3032
{
31-
voxelArray->copyTuple(neighbor, featureIdIndex);
33+
if(const int32 fId = featureIds.getValue(neighbor); fId >= 0)
34+
{
35+
voxelArray->copyTuple(neighbor, featureIdIndex);
36+
}
3237
}
3338
}
3439
return {};

0 commit comments

Comments
 (0)