Fix segfault when reporting error during install

flatpak_dir_install was returning FALSE but leaving error to NULL, which
would crash when printing the error.

Fixes #3646
This commit is contained in:
Léo Stefanesco
2020-06-04 15:32:12 +02:00
committed by Alexander Larsson
parent 1735d88f01
commit 66dfb63075
2 changed files with 12 additions and 7 deletions

View File

@@ -473,8 +473,10 @@ operation_error (FlatpakTransaction *transaction,
msg = g_strdup_printf (_("%s needs a later flatpak version"), flatpak_ref_get_name (rref));
else if (g_error_matches (error, FLATPAK_ERROR, FLATPAK_ERROR_OUT_OF_SPACE))
msg = g_strdup (_("Not enough disk space to complete this operation"));
else
else if (error)
msg = g_strdup (error->message);
else
msg = g_strdup (_("(internal error, please report)"));
if (!non_fatal && self->first_operation_error == NULL)
g_propagate_prefixed_error (&self->first_operation_error,

View File

@@ -8720,12 +8720,15 @@ flatpak_dir_install (FlatpakDir *self,
if (is_revokefs_pull &&
!flatpak_dir_revokefs_fuse_unmount (&child_repo, &child_repo_lock, mnt_dir, &local_error))
{
g_warning ("Could not unmount revokefs-fuse filesystem at %s: %s", mnt_dir, local_error->message);
flatpak_dir_unmount_and_cancel_pull (self,
FLATPAK_HELPER_CANCEL_PULL_FLAGS_PRESERVE_PULL,
cancellable,
&child_repo, &child_repo_lock,
mnt_dir, src_dir);
g_propagate_prefixed_error (error, g_steal_pointer (&local_error),
_("Could not unmount revokefs-fuse filesystem at %s: "), mnt_dir);
if (src_dir &&
!flatpak_dir_system_helper_call_cancel_pull (self,
FLATPAK_HELPER_CANCEL_PULL_FLAGS_PRESERVE_PULL,
installation ? installation : "",
src_dir, cancellable, &local_error))
g_warning ("Error cancelling ongoing pull at %s: %s", src_dir, local_error->message);
return FALSE;
}
}