hku-mars / FAST_LIO

A computationally efficient and robust LiDAR-inertial odometry (LIO) package
GNU General Public License v2.0
2.78k stars 936 forks source link

bug report, index out of bound #245

Closed snakehaihai closed 1 year ago

snakehaihai commented 1 year ago

In this code, there is a minor bug that can cause seg fault.

void Preprocess::give_feature(pcl::PointCloud<PointType> &pl, vector<orgtype> &types)
{
  int plsize = pl.size();
  int plsize2;
  if(plsize == 0)
  {
    printf("something wrong\n");
    return;
  }
  uint head = 0;

  while(types[head].range < blind)
  {
    head++;
  }

Suggest add check before to prevent potential out-of-bounds access:


while (head < types.size() && types[head].range < blind)
{
    head++;
}
Ecstasy-EC commented 1 year ago

Thanks! I will fix it later.