[gnome-software/1792-crash-under-gs_flatpak_refine_app_unlocked] flatpak: Make sure the XbSilo is non-NULL when passing it to other functions
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1792-crash-under-gs_flatpak_refine_app_unlocked] flatpak: Make sure the XbSilo is non-NULL when passing it to other functions
- Date: Tue, 7 Jun 2022 10:24:09 +0000 (UTC)
commit 2454ce027f472abad26c46e80111a00f04cd2c29
Author: Milan Crha <mcrha redhat com>
Date: Tue Jun 7 12:06:59 2022 +0200
flatpak: Make sure the XbSilo is non-NULL when passing it to other functions
It can happen the GsFlatpak::XbSilo is NULL even after refreshing
the GsFlatpak, thus make sure the functions properly end with an error,
rather than expecting the XbSilo is always non-NULL.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1792
plugins/flatpak/gs-flatpak.c | 82 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 82 insertions(+)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 7880071e9..19570eefa 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -3199,6 +3199,20 @@ gs_flatpak_refine_app_unlocked (GsFlatpak *self,
locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+ if (self->silo == NULL) {
+ g_clear_pointer (&locker, g_rw_lock_reader_locker_free);
+ if (!gs_flatpak_rescan_appstream_store (self, interactive, cancellable, error))
+ return FALSE;
+
+ locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+ if (self->silo == NULL) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "failed to setup XbSilo for '%s'",
+ gs_flatpak_get_id (self));
+ return FALSE;
+ }
+ }
+
/* always do AppStream properties */
if (!gs_flatpak_refine_appstream (self, app, self->silo, flags, interactive, cancellable, error))
return FALSE;
@@ -3398,6 +3412,13 @@ gs_flatpak_refine_wildcard (GsFlatpak *self, GsApp *app,
locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+ if (self->silo == NULL) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "failed to setup XbSilo for '%s'",
+ gs_flatpak_get_id (self));
+ return FALSE;
+ }
+
/* find all apps when matching any prefixes */
xpath = g_strdup_printf ("components/component/id[text()='%s']/..", id);
components = xb_silo_query (self->silo, xpath, 0, &error_local);
@@ -3950,6 +3971,13 @@ gs_flatpak_search (GsFlatpak *self,
return FALSE;
locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+ if (self->silo == NULL) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "failed to setup XbSilo for '%s'",
+ gs_flatpak_get_id (self));
+ return FALSE;
+ }
+
if (!gs_appstream_search (self->plugin, self->silo, values, list_tmp,
cancellable, error))
return FALSE;
@@ -4024,6 +4052,12 @@ gs_flatpak_search_developer_apps (GsFlatpak *self,
return FALSE;
locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+ if (self->silo == NULL) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "failed to setup XbSilo for '%s'",
+ gs_flatpak_get_id (self));
+ return FALSE;
+ }
if (!gs_appstream_search_developer_apps (self->plugin, self->silo, values, list_tmp,
cancellable, error))
return FALSE;
@@ -4093,6 +4127,12 @@ gs_flatpak_add_category_apps (GsFlatpak *self,
return FALSE;
locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+ if (self->silo == NULL) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "failed to setup XbSilo for '%s'",
+ gs_flatpak_get_id (self));
+ return FALSE;
+ }
return gs_appstream_add_category_apps (self->plugin, self->silo,
category, list,
cancellable, error);
@@ -4111,6 +4151,12 @@ gs_flatpak_add_categories (GsFlatpak *self,
return FALSE;
locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+ if (self->silo == NULL) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "failed to setup XbSilo for '%s'",
+ gs_flatpak_get_id (self));
+ return FALSE;
+ }
return gs_appstream_add_categories (self->silo,
list, cancellable, error);
}
@@ -4129,6 +4175,12 @@ gs_flatpak_add_popular (GsFlatpak *self,
return FALSE;
locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+ if (self->silo == NULL) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "failed to setup XbSilo for '%s'",
+ gs_flatpak_get_id (self));
+ return FALSE;
+ }
if (!gs_appstream_add_popular (self->silo, list_tmp,
cancellable, error))
return FALSE;
@@ -4152,6 +4204,12 @@ gs_flatpak_add_featured (GsFlatpak *self,
return FALSE;
locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+ if (self->silo == NULL) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "failed to setup XbSilo for '%s'",
+ gs_flatpak_get_id (self));
+ return FALSE;
+ }
if (!gs_appstream_add_featured (self->silo, list_tmp,
cancellable, error))
return FALSE;
@@ -4175,6 +4233,12 @@ gs_flatpak_add_deployment_featured (GsFlatpak *self,
return FALSE;
locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+ if (self->silo == NULL) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "failed to setup XbSilo for '%s'",
+ gs_flatpak_get_id (self));
+ return FALSE;
+ }
return gs_appstream_add_deployment_featured (self->silo, deployments, list, cancellable, error);
}
@@ -4193,6 +4257,12 @@ gs_flatpak_add_alternates (GsFlatpak *self,
return FALSE;
locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+ if (self->silo == NULL) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "failed to setup XbSilo for '%s'",
+ gs_flatpak_get_id (self));
+ return FALSE;
+ }
if (!gs_appstream_add_alternates (self->silo, app, list_tmp,
cancellable, error))
return FALSE;
@@ -4217,6 +4287,12 @@ gs_flatpak_add_recent (GsFlatpak *self,
return FALSE;
locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+ if (self->silo == NULL) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "failed to setup XbSilo for '%s'",
+ gs_flatpak_get_id (self));
+ return FALSE;
+ }
if (!gs_appstream_add_recent (self->plugin, self->silo, list_tmp, age,
cancellable, error))
return FALSE;
@@ -4242,6 +4318,12 @@ gs_flatpak_url_to_app (GsFlatpak *self,
return FALSE;
locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+ if (self->silo == NULL) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "failed to setup XbSilo for '%s'",
+ gs_flatpak_get_id (self));
+ return FALSE;
+ }
if (!gs_appstream_url_to_app (self->plugin, self->silo, list_tmp, url, cancellable, error))
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]