From 35aef1fa2cd65e6c8c4906c2011cf3582179bcd6 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 12 Dec 2017 10:10:16 +0100 Subject: [PATCH] system-helper: Fix crashes in progress callbacks when pulling I got weird crashes in the local repo pull case where the default progress reporting callback tried to get some unset key on the progress. We don't want any progress reporting anyway, so fix this by dropping all progress reporting. Closes: #1243 Approved by: alexlarsson --- system-helper/flatpak-system-helper.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/system-helper/flatpak-system-helper.c b/system-helper/flatpak-system-helper.c index aafec9c7..6c26fd1e 100644 --- a/system-helper/flatpak-system-helper.c +++ b/system-helper/flatpak-system-helper.c @@ -135,6 +135,11 @@ dir_get_system (const char *installation, GError **error) return system; } +static void +no_progress_cb (OstreeAsyncProgress *progress, gpointer user_data) +{ +} + static gboolean handle_deploy (FlatpakSystemHelper *object, GDBusMethodInvocation *invocation, @@ -149,6 +154,7 @@ handle_deploy (FlatpakSystemHelper *object, g_autoptr(GFile) path = g_file_new_for_path (arg_repo_path); g_autoptr(GError) error = NULL; g_autoptr(GFile) deploy_dir = NULL; + g_autoptr(OstreeAsyncProgress) ostree_progress = NULL; gboolean is_update; gboolean is_oci; gboolean no_deploy; @@ -303,11 +309,13 @@ handle_deploy (FlatpakSystemHelper *object, main_context = g_main_context_new (); g_main_context_push_thread_default (main_context); + ostree_progress = ostree_async_progress_new_and_connect (no_progress_cb, NULL); + if (!flatpak_dir_pull_untrusted_local (system, arg_repo_path, arg_origin, arg_ref, (const char **) arg_subpaths, - NULL, + ostree_progress, NULL, &error)) { g_main_context_pop_thread_default (main_context); @@ -316,6 +324,9 @@ handle_deploy (FlatpakSystemHelper *object, return TRUE; } g_main_context_pop_thread_default (main_context); + + if (ostree_progress) + ostree_async_progress_finish (ostree_progress); } else if (local_pull) { @@ -340,8 +351,10 @@ handle_deploy (FlatpakSystemHelper *object, main_context = g_main_context_new (); g_main_context_push_thread_default (main_context); + ostree_progress = ostree_async_progress_new_and_connect (no_progress_cb, NULL); + if (!flatpak_dir_pull (system, arg_origin, arg_ref, NULL, NULL, (const char **)arg_subpaths, NULL, - FLATPAK_PULL_FLAGS_NONE, OSTREE_REPO_PULL_FLAGS_UNTRUSTED, NULL, + FLATPAK_PULL_FLAGS_NONE, OSTREE_REPO_PULL_FLAGS_UNTRUSTED, ostree_progress, NULL, &error)) { g_main_context_pop_thread_default (main_context); @@ -349,7 +362,11 @@ handle_deploy (FlatpakSystemHelper *object, "Error pulling from repo: %s", error->message); return TRUE; } + g_main_context_pop_thread_default (main_context); + + if (ostree_progress) + ostree_async_progress_finish (ostree_progress); } if (!no_deploy)