Skip to content

Commit

Permalink
segfault if the range.size < filter_window
Browse files Browse the repository at this point in the history
  • Loading branch information
Arjanboeve committed Jun 14, 2021
1 parent ac38dfc commit cf7af51
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/speckle_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ bool LaserScanSpeckleFilter::update(const sensor_msgs::LaserScan& input_scan, se
{
output_scan = input_scan;
std::vector<bool> valid_ranges(output_scan.ranges.size(), false);
for (size_t idx = 0; idx < output_scan.ranges.size() - config_.filter_window + 1; ++idx)

/*Check if range size is big enough to set the window */
size_t maxIdx = output_scan.ranges.size();
if(maxIdx > config_.filter_window && config_.filter_window > 0) maxIdx -= (config_.filter_window-1);

for (size_t idx = 0; idx < maxIdx; ++idx)
{
bool window_valid = validator_->checkWindowValid(
output_scan, idx, config_.filter_window, config_.max_range_difference);
Expand Down

0 comments on commit cf7af51

Please sign in to comment.