summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-11-26 14:21:53 -0500
committerMatthias Clasen <mclasen@redhat.com>2020-11-26 14:28:58 -0500
commit06c866b99fbbbd72fdf80000094d314668e25182 (patch)
tree3a7bfd6646fdbea8929af89173adc4e94f5ef02a
parent0ede4fd2fb9360521882a1c4c313c164550659b5 (diff)
downloadgtk+-06c866b99fbbbd72fdf80000094d314668e25182.tar.gz
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.
-rw-r--r--gsk/gskpath.c15
1 files changed, 15 insertions, 0 deletions
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);