Could `startX` ever equal `endX` at this point? If it can, this will cause a division by zero. Similarly, if `startY` equals `endY` then `slope` will be `0` and there will be division by zero below (lines 675 and 685).

However, it's possible that I've not spotted the check that ensures `startX != endX && startY != endY` by the time we get to this line.