Backport !1617 “Fix a few leaks found while valgrinding unit tests” to gnome-43

Trivial backport of two of the patches from !1617 (merged), which apply to gnome-43.

Merge request reports