Initialize the direction on the first/last points of the curve. The fix from 23a4149778 exposed this error.
23a4149778