From f4b26af2554aa546740409ef2da91a62397cd159 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 13 Feb 2019 08:38:30 -0500 Subject: [PATCH] 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); }