[gnome-software/gnome-3-22] Fix crash when removing lazy-loaded applications
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-22] Fix crash when removing lazy-loaded applications
- Date: Mon, 16 Jan 2017 14:34:40 +0000 (UTC)
commit e535815a8e518072b8546fd377c52fd5e06d4bfd
Author: Richard Hughes <richard hughsie com>
Date: Tue Dec 13 20:06:57 2016 +0000
Fix crash when removing lazy-loaded applications
src/gs-app-list.c | 14 +++++++++-----
src/gs-self-test.c | 9 +++++++++
2 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-app-list.c b/src/gs-app-list.c
index 6785b30..bcf8463 100644
--- a/src/gs-app-list.c
+++ b/src/gs-app-list.c
@@ -166,11 +166,15 @@ gs_app_list_remove (GsAppList *list, GsApp *app)
/* remove, or ignore if not found */
unique_id = gs_app_get_unique_id (app);
- app_tmp = g_hash_table_lookup (list->hash_by_id, unique_id);
- if (app_tmp == NULL)
- return;
- g_ptr_array_remove (list->array, app_tmp);
- g_hash_table_remove (list->hash_by_id, unique_id);
+ if (unique_id != NULL) {
+ app_tmp = g_hash_table_lookup (list->hash_by_id, unique_id);
+ if (app_tmp == NULL)
+ return;
+ g_hash_table_remove (list->hash_by_id, unique_id);
+ g_ptr_array_remove (list->array, app_tmp);
+ } else {
+ g_ptr_array_remove (list->array, app);
+ }
}
/**
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index fd76b63..902a2ed 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -201,6 +201,15 @@ gs_plugin_func (void)
g_assert_cmpint (gs_app_list_length (list_remove), ==, 1);
g_object_unref (list_remove);
+ /* remove lazy-loaded app */
+ list_remove = gs_app_list_new ();
+ app = gs_app_new (NULL);
+ gs_app_list_add (list_remove, app);
+ gs_app_list_remove (list_remove, app);
+ g_assert_cmpint (gs_app_list_length (list_remove), ==, 0);
+ g_object_unref (app);
+ g_object_unref (list_remove);
+
/* respect priority when deduplicating */
list = gs_app_list_new ();
app = gs_app_new ("e");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]