From 5e2e771ece06f37b3f9f60089ede718fa8bcaf8e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 8 Feb 2023 18:24:01 +0000 Subject: [PATCH] list: Handle error in flatpak_dir_load_deployed() flatpak_dir_load_deployed() can fail and return NULL. If that happens, there is a semi-installed but broken app, and we should show a warning rather than crashing. Resolves: https://github.com/flatpak/flatpak/issues/5293 Signed-off-by: Simon McVittie --- app/flatpak-builtins-list.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/flatpak-builtins-list.c b/app/flatpak-builtins-list.c index 50b93e42..7b3edd20 100644 --- a/app/flatpak-builtins-list.c +++ b/app/flatpak-builtins-list.c @@ -154,6 +154,7 @@ print_table_for_refs (gboolean print_apps, const char *repo = NULL; g_autoptr(FlatpakDeploy) deploy = NULL; g_autoptr(GBytes) deploy_data = NULL; + g_autoptr(GError) local_error = NULL; const char *active; const char *alt_id; const char *eol; @@ -171,7 +172,16 @@ print_table_for_refs (gboolean print_apps, if (arch != NULL && !flatpak_decomposed_is_arch (ref, arch)) continue; - deploy = flatpak_dir_load_deployed (dir, ref, NULL, cancellable, NULL); + deploy = flatpak_dir_load_deployed (dir, ref, NULL, cancellable, &local_error); + + if (deploy == NULL) + { + g_warning (_("Unable to load details of %s: %s"), + partial_ref, local_error->message); + g_clear_error (&local_error); + continue; + } + deploy_data = flatpak_deploy_get_deploy_data (deploy, FLATPAK_DEPLOY_VERSION_CURRENT, cancellable, NULL); if (deploy_data == NULL) continue;