[gnome-software] Do not crash if a GsPluginEvent has no unique ID



commit 777ae7f1c51c61be12ec5e0fb5f6e16fd68d7e69
Author: Richard Hughes <richard hughsie com>
Date:   Wed Aug 30 09:35:23 2017 +0100

    Do not crash if a GsPluginEvent has no unique ID
    
    We need to find the root cause of this, but in the meantime don't explode.

 lib/gs-plugin-loader.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index a2f60f5..bf36d62 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -303,6 +303,15 @@ gs_plugin_loader_add_event (GsPluginLoader *plugin_loader, GsPluginEvent *event)
 {
        GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
        g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&priv->events_by_id_mutex);
+
+       /* events should always have a unique ID, either constructed from the
+        * app they are processing or preferably from the GError message */
+       if (gs_plugin_event_get_unique_id (event) == NULL) {
+               g_warning ("failed to add event from action %s",
+                          gs_plugin_action_to_string (gs_plugin_event_get_action (event)));
+               return;
+       }
+
        g_hash_table_insert (priv->events_by_id,
                             g_strdup (gs_plugin_event_get_unique_id (event)),
                             g_object_ref (event));


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