gcontenttype: Fix a potential g_object_unref(NULL) call

This can happen if the g_file_query_info() call fails, returning NULL.

Found with scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
gdbusserver: Fix a potential g_object_unref(NULL) call

This can happen if the hash table lookup for ‘noncefile’ fails, and
hence the first ‘goto out’ is hit, at which point resolver is still
NULL.

Found with scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
gsocketaddress: Add an assertion to help static analysis

The static analyser will check dynamic type assertions and assume that
if they fail, the variable can either have the wrong type, or be NULL
(which is correct). The analyser doesn’t know that other constraints in
the API ensure the variable is non-NULL.

Add a non-null assertion to help the static analyser and shut it up in
this case.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
gunixfdlist: Fix a potential NULL pointer dereference

In the case that (n_fds == 0 && fds == NULL), memcpy() would be called
against a NULL src pointer. Even though the number of bytes to copy is
0, avoid the possibility of a crash by only calling if fds is non-NULL.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
gcontenttype: Fix a potential NULL pointer dereference

If the initial part of the header (‘MIME-TreeMagic’) is valid, but the
following line does not start with ‘[’ (i.e. is not a valid section
line), insert_matchlet() will be called with a NULL match pointer, and
will crash with a NULL pointer dereference.

Fix this by bailing out if a valid section line isn’t encountered before
the first insert_matchlet() call (i.e. between the header line and the
first data line).

Note that this has not been tested against a real treemagic file; the
fix is purely theoretical.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
gunixmounts: Fix a potential strcmp(NULL) call

mntent->mnt_fsname may be NULL at this point; if so, fall to the second
branch and set mount_entry->device_path = NULL.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
gio/tests: Fix a g_return_val_if_fail() in a void function

Should be g_return_if_fail() instead.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
gio/tests: Add non-NULL assertions to help static analysis

These prevent some false positives from the static analyser which are
caused by it not inspecting the invariants of
g_subprocess_communicate[_utf8]_finish() (i.e. that stdout and
stdout_str will always be set unless an error was returned).

They’re also good testing anyway.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
gio/tests: Add a non-NULL assertion to help static analysis

The static analyser (correctly) considers a type check to fail if the
variable is NULL. In this case, the address must be non-NULL as no error
was thrown by g_socket_connection_get_remote_address(), but the static
analyser doesn’t know this.

Add a non-NULL assertion anyway, both to shut the analyser up, and
because it’s good extra testing.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
gio/tests: Add a dynamic type check assertion

This shuts up a static analysis false positive, and adds some extra
checking.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075