Fix apply na overflow
Another thing flagged by ASAN. I am not very familiar with this algorithm so there may be a better way of doing this, but when `n=0` the cython code ends up reading memory one byte to the left of the array
Thanks @WillAyd 