diff options
author | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2019-08-27 07:28:22 +0000 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2019-08-27 07:28:22 +0000 |
commit | 6a9d6c27151f5e5b74f1ed0c3b2ae22cb434def6 (patch) | |
tree | c3cf0f8d1df76f5fca2d724084d44b084f5dee24 | |
parent | a365528f64c13062d91a920d50ae5c77f172e719 (diff) | |
parent | 87c8168980f70fe6cc46bd7a8d88431813a34be0 (diff) | |
download | glib-6a9d6c27151f5e5b74f1ed0c3b2ae22cb434def6.tar.gz |
Merge branch 'backport-966-win32-uri-crash-fix' into 'glib-2-60'
Backport !966 “Resolve "Invalid characters in Open Location dialog crashes GIMP"” to glib-2-60
See merge request GNOME/glib!1061
-rw-r--r-- | gio/gvfs.c | 10 | ||||
-rw-r--r-- | gio/win32/gwinhttpfile.c | 2 | ||||
-rw-r--r-- | gio/win32/gwinhttpvfs.c | 18 |
3 files changed, 21 insertions, 9 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); } /** diff --git a/gio/win32/gwinhttpfile.c b/gio/win32/gwinhttpfile.c index d5df16d91..d6acab7b8 100644 --- a/gio/win32/gwinhttpfile.c +++ b/gio/win32/gwinhttpfile.c @@ -80,7 +80,7 @@ g_winhttp_file_init (GWinHttpFile *winhttp) * @vfs: GWinHttpVfs to use * @uri: URI of the GWinHttpFile to create. * - * Returns: new winhttp #GFile. + * Returns: (nullable): new winhttp #GFile, or %NULL if there was an error constructing it. */ GFile * _g_winhttp_file_new (GWinHttpVfs *vfs, diff --git a/gio/win32/gwinhttpvfs.c b/gio/win32/gwinhttpvfs.c index 038368f81..91d7fed9d 100644 --- a/gio/win32/gwinhttpvfs.c +++ b/gio/win32/gwinhttpvfs.c @@ -165,15 +165,25 @@ g_winhttp_vfs_get_file_for_uri (GVfs *vfs, { GWinHttpVfs *winhttp_vfs = G_WINHTTP_VFS (vfs); int i; + GFile *ret = NULL; /* If it matches one of "our" schemes, handle it */ for (i = 0; i < G_N_ELEMENTS (winhttp_uri_schemes); i++) - if (g_ascii_strncasecmp (uri, winhttp_uri_schemes[i], strlen (winhttp_uri_schemes[i])) == 0 && - uri[strlen (winhttp_uri_schemes[i])] == ':') - return _g_winhttp_file_new (winhttp_vfs, uri); + { + if (g_ascii_strncasecmp (uri, winhttp_uri_schemes[i], strlen (winhttp_uri_schemes[i])) == 0 && + uri[strlen (winhttp_uri_schemes[i])] == ':') + { + ret = _g_winhttp_file_new (winhttp_vfs, uri); + } + } /* For other URIs fallback to the wrapped GVfs */ - return g_vfs_get_file_for_uri (winhttp_vfs->wrapped_vfs, uri); + if (ret == NULL) + ret = g_vfs_get_file_for_uri (winhttp_vfs->wrapped_vfs, uri); + + g_assert (ret != NULL); + + return g_steal_pointer (&ret); } static const gchar * const * |