avoid crash in case of strange curve (self-intersect, loops, ...)