177bbf12df solved the out of bound read
by limiting the input search. However this lead to incorrect
interpolation. This has been fixed by moving the bound check as a
post check.
Pull Request: https://projects.blender.org/blender/blender/pulls/136769