From a1b5bb1507591b5df47c1ce404bd57bc900eef89 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 15 Jan 2016 14:53:34 +0100 Subject: [PATCH] xdg_app_installation_list_remote_refs_sync: Don't crash on weird refs --- lib/xdg-app-installation.c | 7 +++++-- lib/xdg-app-remote-ref.c | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/xdg-app-installation.c b/lib/xdg-app-installation.c index 95a26e48..57379e3d 100644 --- a/lib/xdg-app-installation.c +++ b/lib/xdg-app-installation.c @@ -1052,9 +1052,12 @@ xdg_app_installation_list_remote_refs_sync (XdgAppInstallation *self, { const char *refspec = key; const char *checksum = value; + XdgAppRemoteRef *ref; - g_ptr_array_add (refs, - xdg_app_remote_ref_new (refspec, checksum, remote_name)); + ref = xdg_app_remote_ref_new (refspec, checksum, remote_name); + + if (ref) + g_ptr_array_add (refs, ref); } return g_steal_pointer (&refs); diff --git a/lib/xdg-app-remote-ref.c b/lib/xdg-app-remote-ref.c index d1bdc29e..19eb4b30 100644 --- a/lib/xdg-app-remote-ref.c +++ b/lib/xdg-app-remote-ref.c @@ -137,7 +137,9 @@ xdg_app_remote_ref_new (const char *full_ref, g_auto(GStrv) parts = NULL; XdgAppRemoteRef *ref; - parts = g_strsplit (full_ref, "/", -1); + parts = xdg_app_decompose_ref (full_ref, NULL); + if (parts == NULL) + return NULL; if (strcmp (parts[0], "app") != 0) kind = XDG_APP_REF_KIND_RUNTIME;