Skip to content

Commit

Permalink
Merge pull request ros-perception#118 from eurogroep/segfault_fix
Browse files Browse the repository at this point in the history
fix(speckle_filter): Possible segfault when ranges size was smaller than filter window
  • Loading branch information
jonbinney authored Jun 21, 2021
2 parents 7c77be2 + 2ec5b49 commit 5b40838
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/speckle_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ bool LaserScanSpeckleFilter::update(const sensor_msgs::LaserScan& input_scan, se
{
output_scan = input_scan;
std::vector<bool> valid_ranges(output_scan.ranges.size(), false);

/*Check if range size is big enough to use the filter window */
if (output_scan.ranges.size() <= config_.filter_window + 1)
{
ROS_ERROR("Scan ranges size is too small: size = %i", output_scan.ranges.size());
return false;
}

for (size_t idx = 0; idx < output_scan.ranges.size() - config_.filter_window + 1; ++idx)
{
bool window_valid = validator_->checkWindowValid(
Expand Down

0 comments on commit 5b40838

Please sign in to comment.