Blob Blame History Raw
From 34db1404382cebbfbf170cfba53371d465c1668f Mon Sep 17 00:00:00 2001
From: Michael Catanzaro <mcatanzaro@gnome.org>
Date: Wed, 6 May 2020 10:57:29 -0500
Subject: [PATCH 3/4] appchooserdialog: add g_return to show_more()

We should never get here unless there are more desktop file choices than
the initial list size. We never do; this assertion is just here to
clarify this. (Otherwise, we could have a buffer overrun in the loop
below.)

(cherry picked from commit 878c06a525b05315fe56baae59c19bfd714df638)
---
 src/appchooserdialog.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/appchooserdialog.c b/src/appchooserdialog.c
index b779f43..c0eb4ca 100644
--- a/src/appchooserdialog.c
+++ b/src/appchooserdialog.c
@@ -132,6 +132,8 @@ show_more (AppChooserDialog *dialog)
   gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
   gtk_widget_hide (dialog->more_row);
 
+  g_return_if_fail (g_strv_length ((char **)dialog->choices) > INITIAL_LIST_SIZE);
+
   for (i = INITIAL_LIST_SIZE; dialog->choices[i]; i++)
     {
       g_autofree char *desktop_id = g_strconcat (dialog->choices[i], ".desktop", NULL);
-- 
2.26.2