diff --git a/image_proc/src/nodelets/crop_decimate.cpp b/image_proc/src/nodelets/crop_decimate.cpp index 46a329128..4ecc311f6 100644 --- a/image_proc/src/nodelets/crop_decimate.cpp +++ b/image_proc/src/nodelets/crop_decimate.cpp @@ -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)