Skip to content

VarTrimmedDistOutlierFilter::optimizeInlierRatio() reads uninitialised memory #610

@ryancu7

Description

@ryancu7

Steps to reproduce

  1. Run ICP in a debug build with a VarTrimmedDistOutlierFilter for any reasonable data.

Expected results

ICP should run without any C++ standard library assertions being violated.

Actual results

MSVC C++ runtime stops with error: "cannot seek vector iterator after end". This is due to the following incorrect code in OutlierFiltersImpl.cpp:

	std::vector<T> tmpCumSumSortedDist;
	tmpCumSumSortedDist.reserve(points_nbr);
	std::partial_sum(tmpSortedDist.begin(), tmpSortedDist.end(), tmpCumSumSortedDist.begin());

Discussion

std::partial_sum() requires the vector being written to have the elements already created. The line above calling reserve() allocates memory in the vector (which is how an access violation is probably avoided), but does not change the size of the vector, which is still 0.

Replacing reserve(points_nbr) with resize(tmpSortedDist.size()) will fix this step, but points_nbr (the wrong size) is also used in the lines following this one.

Notes

This is currently found on both master and the latest release (1.4.4).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions