From 6b22cfaf8de5b15fbcc3154913c334f3ddbb4a06 Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Tue, 17 Oct 2017 13:12:24 +0200 Subject: [PATCH] Fix a crash, since subdivisions can be empty. (#543) --- cartographer_ros/cartographer_ros/sensor_bridge.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cartographer_ros/cartographer_ros/sensor_bridge.cc b/cartographer_ros/cartographer_ros/sensor_bridge.cc index a3b2eab..1f2abdb 100644 --- a/cartographer_ros/cartographer_ros/sensor_bridge.cc +++ b/cartographer_ros/cartographer_ros/sensor_bridge.cc @@ -149,6 +149,9 @@ void SensorBridge::HandleLaserScan( points.points.size() * (i + 1) / num_subdivisions_per_laser_scan_; const carto::sensor::PointCloud subdivision( points.points.begin() + start_index, points.points.begin() + end_index); + if (start_index == end_index) { + continue; + } const size_t middle_index = (start_index + end_index) / 2; const carto::common::Time subdivision_time = start_time +