[epiphany/gnome-3-28] location-controller: Don't crash when completion index is invalid



commit f5020f8609f700a6467a78e39278fb991885874d
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Tue Apr 3 16:46:05 2018 -0500

    location-controller: Don't crash when completion index is invalid
    
    I still don't understand how this can happen, but let's avoid crashing
    when it does.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783756

 src/ephy-location-controller.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index d540d8b..1f1d629 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -298,8 +298,8 @@ action_activated_cb (GtkEntryCompletion     *completion,
                      EphyLocationController *controller)
 {
   GtkWidget *entry;
+  char *url = NULL;
   char *content;
-  char *url;
   char **engine_names;
 
   entry = gtk_entry_completion_get_entry (completion);
@@ -308,13 +308,15 @@ action_activated_cb (GtkEntryCompletion     *completion,
     return;
 
   engine_names = ephy_search_engine_manager_get_names (controller->search_engine_manager);
-  url = ephy_search_engine_manager_build_search_address (controller->search_engine_manager,
-                                                         engine_names[index],
-                                                         content);
-  g_strfreev (engine_names);
+  if (index < g_strv_length (engine_names)) {
+    url = ephy_search_engine_manager_build_search_address (controller->search_engine_manager,
+                                                           engine_names[index],
+                                                           content);
+    ephy_link_open (EPHY_LINK (controller), url, NULL,
+                    ephy_link_flags_from_current_event ());
+  }
 
-  ephy_link_open (EPHY_LINK (controller), url, NULL,
-                  ephy_link_flags_from_current_event ());
+  g_strfreev (engine_names);
   g_free (content);
   g_free (url);
 }


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