diff options
author | Philip Withnall <withnall@endlessm.com> | 2019-07-02 12:08:45 +0100 |
---|---|---|
committer | Philip Withnall <withnall@endlessm.com> | 2019-08-27 08:24:15 +0300 |
commit | 9dac535c8c909114237b833c44b406d2037b926b (patch) | |
tree | 70e0f4542e7d31a7d299ff485b3bbdf63510733b | |
parent | a365528f64c13062d91a920d50ae5c77f172e719 (diff) | |
download | glib-9dac535c8c909114237b833c44b406d2037b926b.tar.gz |
gvfs: Add an assertion to check that get_file_for_uri() is never NULL
It cannot return a NULL value, as none of its callers have error
handlng. Add an assertion to check the values returned by the VFS
implementations.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #1819
-rw-r--r-- | gio/gvfs.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gio/gvfs.c b/gio/gvfs.c index 5805a7904..3475624cf 100644 --- a/gio/gvfs.c +++ b/gio/gvfs.c @@ -236,7 +236,7 @@ g_vfs_get_file_for_uri (GVfs *vfs, const char *uri) { GVfsClass *class; - GFile *ret; + GFile *ret = NULL; g_return_val_if_fail (G_IS_VFS (vfs), NULL); g_return_val_if_fail (uri != NULL, NULL); @@ -244,10 +244,12 @@ g_vfs_get_file_for_uri (GVfs *vfs, class = G_VFS_GET_CLASS (vfs); ret = get_file_for_uri_internal (vfs, uri); - if (ret) - return ret; + if (!ret) + ret = (* class->get_file_for_uri) (vfs, uri); + + g_assert (ret != NULL); - return (* class->get_file_for_uri) (vfs, uri); + return g_steal_pointer (&ret); } /** |