flatpak / xdg-desktop-portal-gtk

Gtk implementation of xdg-desktop-portal
GNU Lesser General Public License v2.1
130 stars 102 forks source link

filechooser: Fix crash when opening a file chooser with single filter set #448

Closed sidt4 closed 1 year ago

sidt4 commented 1 year ago

gtk_file_filter_new_from_gvariant () returns a GtkFileFilter which is a floating reference in GTK3. gtk_file_chooser_set_filter () takes ownership of this floating reference. So, we take a ref to the filter to account for the autoptr cleanup.

Note that this happens only when we have a single filter ( with 1 or more rules ) set via gtk_file_chooser_set_filter () in the app.

sidt4 commented 1 year ago

Steps to reproduce in GNOME.

  1. Stop portal service using below command
$ systemctl --user stop xdg-desktop-portal*.service
  1. Disable xdg-desktop-portal-gnome portal using below command.
# cd /usr/share/xdg-desktop-portal/portals/
# mv gnome.portal gnome-disabled.portal
  1. Install and start GNOME Boxes flatpak
$ flatpak install org.gnome.Boxes
$ flatpak run org.gnome.Boxes
  1. Click + button in top left and select Install from file menu option.
  2. There should be no response, as xdg-desktop-portal-gtk has crashed.
  3. Verify from journalctl that xdg-desktop-portal-gtk has crashed.
  4. Undo step [2].