[gnome-software] Never crash when the flatpak origin is NULL
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Never crash when the flatpak origin is NULL
- Date: Tue, 15 Nov 2016 13:21:06 +0000 (UTC)
commit 1ae65997ce1b4e09d67fe2722e64f267b39c403c
Author: Richard Hughes <richard hughsie com>
Date: Tue Nov 15 12:52:26 2016 +0000
Never crash when the flatpak origin is NULL
I'm not completely sure how this can happen, but it's something to do with a
failed flatpak install happening before the refine operation.
Either way, checking the value before we pass it to libflatpak is probably a
good idea.
src/plugins/gs-flatpak.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index dc0951d..96a863a 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -1182,6 +1182,10 @@ gs_plugin_refine_item_origin_hostname (GsFlatpak *self, GsApp *app,
if (gs_app_get_origin_hostname (app) != NULL)
return TRUE;
+ /* no origin */
+ if (gs_app_get_origin (app) == NULL)
+ return TRUE;
+
/* get the remote */
xremote = flatpak_installation_get_remote_by_name (self->installation,
gs_app_get_origin (app),
@@ -1654,6 +1658,16 @@ gs_plugin_refine_item_metadata (GsFlatpak *self,
} else {
g_autoptr(FlatpakRef) xref = NULL;
+ /* no origin */
+ if (gs_app_get_origin (app) == NULL) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_NOT_SUPPORTED,
+ "no origin set for %s",
+ gs_app_get_unique_id (app));
+ return FALSE;
+ }
+
/* fetch from the server */
xref = gs_flatpak_create_fake_ref (app, error);
if (xref == NULL)
@@ -1772,6 +1786,16 @@ gs_plugin_refine_item_size (GsFlatpak *self,
} else {
g_autoptr(FlatpakRef) xref = NULL;
g_autoptr(GError) error_local = NULL;
+
+ /* no origin */
+ if (gs_app_get_origin (app) == NULL) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_NOT_SUPPORTED,
+ "no origin set for %s",
+ gs_app_get_unique_id (app));
+ return FALSE;
+ }
xref = gs_flatpak_create_fake_ref (app, error);
if (xref == NULL)
return FALSE;
@@ -2176,6 +2200,15 @@ gs_flatpak_app_install (GsFlatpak *self,
app,
cancellable, error);
} else {
+ /* no origin */
+ if (gs_app_get_origin (app) == NULL) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_NOT_SUPPORTED,
+ "no origin set for %s",
+ gs_app_get_unique_id (app));
+ return FALSE;
+ }
g_debug ("installing %s", gs_app_get_id (app));
xref = flatpak_installation_install (self->installation,
gs_app_get_origin (app),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]