[gtk/wip/baedert/for-master: 26/27] text: Assert that we have ranges before using them



commit 7235472a5857189422fb5a9731ce1b18b7bc83c9
Author: Timm Bäder <mail baedert org>
Date:   Mon May 18 19:39:32 2020 +0200

    text: Assert that we have ranges before using them
    
    We never hit this code path otherwise but let's make sure.

 gtk/gtktext.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 4dc3664a0c..d60e036208 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -2944,6 +2944,8 @@ gtk_text_drag_gesture_update (GtkGestureDrag *gesture,
           text = _gtk_text_get_selected_text (self);
           gtk_text_get_pixel_ranges (self, &ranges, &n_ranges);
 
+          g_assert (n_ranges > 0);
+
           if (priv->editable)
             actions = GDK_ACTION_COPY|GDK_ACTION_MOVE;
           else
@@ -2968,7 +2970,7 @@ gtk_text_drag_gesture_update (GtkGestureDrag *gesture,
           priv->drag = drag;
 
           g_object_unref (drag);
-          
+
           g_free (ranges);
           g_free (text);
 


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