app: Fix a use-after-free in flatpak_find_installed_pref()
app: Fix a use-after-free in flatpak_find_installed_pref()

Currently "flatpak --installation=default info ..." leads to an
assertion failure:

$ flatpak --installation=default info us.zoom.Zoom

(flatpak info:24593): GLib-GObject-CRITICAL **: 10:01:36.040: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

This is because in flatpak_find_installed_pref(), we set "dir =
installation_dir" but then installation_dir is freed by g_autoptr before
we try to return dir.

Fix the problem by stealing the pointer, and doing the same for the
other places dir is set.

Closes: #3077
Approved by: alexlarsson

flatpak/flatpak,matthiasclasen/flatpak,flatpak/flatpak,matthiasclasen/flatpak,matthiasclasen/flatpak,flatpak/flatpak,matthiasclasen/flatpak,flatpak/flatpak,flatpak/flatpak,matthiasclasen/flatpak