From e0269d0530a4b88eab7a935cd996f6ee1007b229 Mon Sep 17 00:00:00 2001 From: vcarpani Date: Thu, 30 Dec 2021 16:38:37 +0100 Subject: [PATCH 1/2] Check for width in assign(). --- common/include/pcl/point_cloud.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/include/pcl/point_cloud.h b/common/include/pcl/point_cloud.h index 9440c92249b..09fadec23da 100644 --- a/common/include/pcl/point_cloud.h +++ b/common/include/pcl/point_cloud.h @@ -595,6 +595,12 @@ namespace pcl inline void assign(InputIterator first, InputIterator last, index_t new_width) { + if (new_width == 0) { + PCL_WARN("Assignment with new_width equal to 0," + "setting width to size of the cloud and height to 1\n"); + return assign(std::move(first), std::move(last)); + } + points.assign(std::move(first), std::move(last)); width = new_width; height = size() / width; @@ -631,6 +637,11 @@ namespace pcl void inline assign(std::initializer_list ilist, index_t new_width) { + if (new_width == 0) { + PCL_WARN("Assignment with new_width equal to 0," + "setting width to size of the cloud and height to 1\n"); + return assign(std::move{ilist)); + } points.assign(std::move(ilist)); width = new_width; height = size() / width; From e1704e22e902fac4efd46dee74fd4a61639c8072 Mon Sep 17 00:00:00 2001 From: vcarpani <38493091+vcarpani@users.noreply.github.com> Date: Sun, 2 Jan 2022 12:15:52 +0100 Subject: [PATCH 2/2] Update common/include/pcl/point_cloud.h Co-authored-by: Markus Vieth <39675748+mvieth@users.noreply.github.com> --- common/include/pcl/point_cloud.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/include/pcl/point_cloud.h b/common/include/pcl/point_cloud.h index 09fadec23da..fa2172df178 100644 --- a/common/include/pcl/point_cloud.h +++ b/common/include/pcl/point_cloud.h @@ -640,7 +640,7 @@ namespace pcl if (new_width == 0) { PCL_WARN("Assignment with new_width equal to 0," "setting width to size of the cloud and height to 1\n"); - return assign(std::move{ilist)); + return assign(std::move(ilist)); } points.assign(std::move(ilist)); width = new_width;