avoid infinite loop triggered by embedded \r characters
Fix polygon clipping code when intersections are degenerate