In Util/MetFunction.cpp:358 the function linInterpMetData declares the index of the met data cell below the target interpolation point as an unsigned int std::size_t idx_x1;.
Later we can assign it i_Z - 1; which can be negative if i_Z the nearest cell to the target point is index 0. This means that the target point is outside the met data and we should throw an error, but because idx_x1 is unsigned it wraps to whatever is the max value for that type and the subsequent check never catches the out of bounds:
if(idx_x1 < 0) {
throw std::range_error("Input flight altitude out of range of met. data!");
}
I introduced this bug when I was cleaning compiler warnings on int to std::size_t conversions for vector indexing in #24. I don't think anyone encountered this because most people pass the weather column from the surface to a bit above cruise but this is incorrect.
In
Util/MetFunction.cpp:358the functionlinInterpMetDatadeclares the index of the met data cell below the target interpolation point as an unsigned intstd::size_t idx_x1;.Later we can assign it
i_Z - 1;which can be negative ifi_Zthe nearest cell to the target point is index 0. This means that the target point is outside the met data and we should throw an error, but becauseidx_x1is unsigned it wraps to whatever is the max value for that type and the subsequent check never catches the out of bounds:I introduced this bug when I was cleaning compiler warnings on
inttostd::size_tconversions for vector indexing in #24. I don't think anyone encountered this because most people pass the weather column from the surface to a bit above cruise but this is incorrect.