From 06c866b99fbbbd72fdf80000094d314668e25182 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 26 Nov 2020 14:21:53 -0500 Subject: [PATCH] path: Handle degenerate paths without crashing When calling get_point on a path which only contains a move, we were crashing. Fix this by adding the same special case handling that get_closest_point already has. --- gsk/gskpath.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gsk/gskpath.c b/gsk/gskpath.c index 10c93abed1..896a58a544 100644 --- a/gsk/gskpath.c +++ b/gsk/gskpath.c @@ -1003,6 +1003,9 @@ gsk_standard_contour_measure_add_point (const graphene_point_t *from, float seg_length; seg_length = graphene_point_distance (from, to, NULL, NULL); + if (seg_length == 0) + return; + decomp->measure.end += seg_length; decomp->measure.start_progress = from_progress; decomp->measure.end_progress = to_progress; @@ -1140,6 +1143,18 @@ gsk_standard_contour_get_point (const GskContour *contour, float progress; GskStandardContourMeasure *measure; + if (array->len == 0) + { + /* This is the special case for point-only */ + if (pos) + *pos = self->points[0]; + + if (tangent) + *tangent = *graphene_vec2_x_axis (); + + return; + } + if (!g_array_binary_search (array, &distance, gsk_standard_contour_find_measure, &index)) index = array->len - 1; measure = &g_array_index (array, GskStandardContourMeasure, index);