[gtk/matthiasc/lottie2] path: Handle degenerate paths without crashing



commit 06c866b99fbbbd72fdf80000094d314668e25182
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Nov 26 14:21:53 2020 -0500

    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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]