It seems that either you should also skip angles that equal the value of angle_max here:
Or make the number of range readings one item larger here:
Otherwise you'll have an out-of-bounds array element access when one day there is an angle of the value angle_max.
Note that I have posted a question here about how many values the sensor_msgs::LaserScan should actually contain, because I'm not sure if angle_max really is supposed to be excluded from the range of values.