[gnome-software] trivial: Do not crash when loading an invalid runtime
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Do not crash when loading an invalid runtime
- Date: Wed, 22 Feb 2017 19:36:07 +0000 (UTC)
commit fe78403aa920f245480fe3a79a7c9b963a1da00c
Author: Richard Hughes <richard hughsie com>
Date: Wed Feb 22 12:47:45 2017 +0000
trivial: Do not crash when loading an invalid runtime
Including 'runtime=foo' in the metadata file for a *runtime* makes gnome-software explode.
.../app-with-runtime/org.test.Runtime/metadata | 1 -
src/gs-app.c | 4 ++++
src/plugins/gs-appstream.c | 5 +++++
3 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/data/tests/flatpak/app-with-runtime/org.test.Runtime/metadata
b/data/tests/flatpak/app-with-runtime/org.test.Runtime/metadata
index cf5655d..16f0fa1 100644
--- a/data/tests/flatpak/app-with-runtime/org.test.Runtime/metadata
+++ b/data/tests/flatpak/app-with-runtime/org.test.Runtime/metadata
@@ -1,4 +1,3 @@
[Runtime]
name=org.test.Runtime
-runtime=org.test.Runtime/x86_64/master
sdk=org.test.Runtime/x86_64/master
diff --git a/src/gs-app.c b/src/gs-app.c
index 6201cc2..1f17318 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -1542,6 +1542,8 @@ gs_app_set_runtime (GsApp *app, GsApp *runtime)
{
g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&app->mutex);
g_return_if_fail (GS_IS_APP (app));
+ g_return_if_fail (app != runtime);
+ g_return_if_fail (runtime->kind == AS_APP_KIND_RUNTIME);
g_set_object (&app->runtime, runtime);
}
@@ -1576,6 +1578,8 @@ gs_app_set_update_runtime (GsApp *app, GsApp *runtime)
{
g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&app->mutex);
g_return_if_fail (GS_IS_APP (app));
+ g_return_if_fail (app != runtime);
+ g_return_if_fail (runtime->kind == AS_APP_KIND_RUNTIME);
g_set_object (&app->update_runtime, runtime);
}
diff --git a/src/plugins/gs-appstream.c b/src/plugins/gs-appstream.c
index 40be14a..40f9066 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -371,6 +371,11 @@ gs_refine_item_management_plugin (GsPlugin *plugin, GsApp *app, AsApp *item)
g_autoptr(GsApp) app2 = NULL;
app2 = gs_appstream_create_runtime (plugin, app, runtime);
if (app2 != NULL) {
+ if (app == app2) {
+ g_warning ("%s runtime cannot have runtime!",
+ gs_app_get_unique_id (app));
+ break;
+ }
g_debug ("runtime for %s is %s",
gs_app_get_unique_id (app),
runtime);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]