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 <smcv@collabora.com>
This commit is contained in:
Simon McVittie
2023-02-08 18:24:01 +00:00
parent 5b2295508f
commit 5e2e771ece

View File

@@ -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;