Fix various scan-build warnings

Philip Withnall requested to merge pwithnall/glib:scan-build-fixes into main

See the commit messages. These commits fix various warnings from scan-build (which you can see in the most recent scan-build CI run). I don’t think any of the warnings are bugs which would actually be hit in practice. I’ve filed !2627 (merged) for one memory leak scan-build found which could be hit in practice. There are still more scan-build warnings to investigate.

Signed-off-by: Philip Withnall

Helps: #1767

Merge request reports