The code was not taking the endpoint of the first segment into account. This was reported in bug 604747.