Skip to content

Commit

Permalink
Merge pull request #423 from lucasw/crop_decimate_resolution_change
Browse files Browse the repository at this point in the history
Avoid crashing when the x or y offset is too large
  • Loading branch information
Joshua Whitley committed Jul 19, 2019
2 parents 762e34b + 133c8d4 commit bf90bd4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions image_proc/src/nodelets/crop_decimate.cpp
Expand Up @@ -196,7 +196,19 @@ void CropDecimateNodelet::imageCb(const sensor_msgs::ImageConstPtr& image_msg,
}

int max_width = image_msg->width - config.x_offset;
if (max_width <= 0)
{
ROS_WARN_STREAM("x offset is outside the input image width: "
<< image_msg->width << ", x offset: " << config.x_offset);
return;
}
int max_height = image_msg->height - config.y_offset;
if (max_height <= 0)
{
ROS_WARN_STREAM("y offset is outside the input image height: "
<< image_msg->height << ", y offset: " << config.y_offset);
return;
}
int width = config.width;
int height = config.height;
if (width == 0 || width > max_width)
Expand Down

0 comments on commit bf90bd4

Please sign in to comment.