Blame SOURCES/0001-appchooserdialog-avoid-crash-when-there-are-few-app-.patch

32b021
From 54ceb35d892ac33c59f4d255359d8184f1b72679 Mon Sep 17 00:00:00 2001
32b021
From: Michael Catanzaro <mcatanzaro@gnome.org>
32b021
Date: Fri, 1 May 2020 17:58:35 -0500
32b021
Subject: [PATCH 1/4] appchooserdialog: avoid crash when there are few app
32b021
 options
32b021
32b021
Problem is the code reads off the end of the choices list when the
32b021
number of choices is less than INITIAL_LIST_SIZE - 1.
32b021
32b021
Fixes #302
32b021
32b021
(cherry picked from commit 7d2b3e270b6a964d8007b5cbb5dfc52c3f9a23ce)
32b021
---
32b021
 src/appchooserdialog.c | 6 +++---
32b021
 1 file changed, 3 insertions(+), 3 deletions(-)
32b021
32b021
diff --git a/src/appchooserdialog.c b/src/appchooserdialog.c
32b021
index 82e362e..0b9f31e 100644
32b021
--- a/src/appchooserdialog.c
32b021
+++ b/src/appchooserdialog.c
32b021
@@ -384,11 +384,11 @@ app_chooser_dialog_new (const char **choices,
32b021
       gtk_label_set_label (GTK_LABEL (dialog->heading), _("Choose an application."));
32b021
     }
32b021
 
32b021
-  ensure_default_is_below (choices, default_id, INITIAL_LIST_SIZE - 1);
32b021
-
32b021
   dialog->choices = g_strdupv ((char **)choices);
32b021
-
32b021
   n_choices = g_strv_length ((char **)choices);
32b021
+
32b021
+  ensure_default_is_below (dialog->choices, default_id, MIN (n_choices, INITIAL_LIST_SIZE - 1));
32b021
+
32b021
   if (n_choices == 0)
32b021
     {
32b021
       gtk_widget_show (dialog->empty_box);
32b021
-- 
32b021
2.26.2
32b021