[gtk] selection model: Add sanity checks



commit f4b26af2554aa546740409ef2da91a62397cd159
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Feb 13 08:38:30 2019 -0500

    selection model: Add sanity checks
    
    It is easy to emit wrong ::selection-changed signals,
    and then bad things will usually happen later. Add
    some sanity checks to gtk_selection_model_selection_changed
    to make this easier to track down.

 gtk/gtkselectionmodel.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/gtk/gtkselectionmodel.c b/gtk/gtkselectionmodel.c
index 0be3961bc2..137928c687 100644
--- a/gtk/gtkselectionmodel.c
+++ b/gtk/gtkselectionmodel.c
@@ -295,6 +295,8 @@ gtk_selection_model_selection_changed (GtkSelectionModel *model,
                                        guint              n_items)
 {
   g_return_if_fail (GTK_IS_SELECTION_MODEL (model));
+  g_return_if_fail (n_items > 0);
+  g_return_if_fail (position + n_items <= g_list_model_get_n_items (G_LIST_MODEL (model)));
 
   g_signal_emit (model, signals[SELECTION_CHANGED], 0, position, n_items);
 }


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