gresourcefile: Fix crash if called with a badly escaped URI

Return an invalid `GFile` instead, as is the custom for VFS functions.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Fixes: #3090
This commit is contained in:
Philip Withnall
2023-08-29 11:22:43 +01:00
parent b35e70a701
commit ed03b1f3f6
2 changed files with 29 additions and 3 deletions

View File

@@ -238,6 +238,7 @@ g_resource_file_new_for_path (const char *path)
return G_FILE (resource);
}
/* Will return %NULL if @uri is malformed */
GFile *
_g_resource_file_new (const char *uri)
{
@@ -245,6 +246,9 @@ _g_resource_file_new (const char *uri)
char *path;
path = g_uri_unescape_string (uri + strlen ("resource:"), NULL);
if (path == NULL)
return NULL;
resource = g_resource_file_new_for_path (path);
g_free (path);