Skip to content

Commit dee87f1

Browse files
Fix pointcloud2 display divide by 0 (ros2#1581) (ros2#1583)
(cherry picked from commit f4f2851) Co-authored-by: Antonio Brandi <[email protected]>
1 parent 09fad21 commit dee87f1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

rviz_default_plugins/src/rviz_default_plugins/displays/pointcloud/point_cloud2_display.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ sensor_msgs::msg::PointCloud2::ConstSharedPtr PointCloud2Display::filterOutInval
104104
filtered->header = cloud->header;
105105
filtered->fields = cloud->fields;
106106
filtered->height = 1;
107-
filtered->width = static_cast<uint32_t>(filtered->data.size() / cloud->point_step);
107+
if (cloud->point_step > 0) {
108+
filtered->width = static_cast<uint32_t>(filtered->data.size() / cloud->point_step);
109+
} else {
110+
filtered->width = 0;
111+
}
108112
filtered->is_bigendian = cloud->is_bigendian;
109113
filtered->point_step = cloud->point_step;
110114
filtered->row_step = filtered->width;

0 commit comments

Comments
 (0)