Fix several leaks
This fixes two leaks, one big (80KB within a few minutes of starting gnome-software) and one small (a few tens of bytes each time).
See the commit messages for details. The flatpak
fix may well fix some threading-related crashes, but I haven’t searched for issues which might match that profile.