diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-08-08 15:03:22 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-08-08 15:14:20 +0200 |
commit | 4927c8c6923991ae68db21e66749c1fb99240b08 (patch) | |
tree | 32d5f98c3b4335b4b66bfa10a5410fc31ba093ec | |
parent | e6341e59bbc248b84a33aef263c90d6eb97e9302 (diff) | |
download | fiv-4927c8c6923991ae68db21e66749c1fb99240b08.tar.gz fiv-4927c8c6923991ae68db21e66749c1fb99240b08.tar.xz fiv-4927c8c6923991ae68db21e66749c1fb99240b08.zip |
Don't crash on orphan URIs
-rw-r--r-- | fiv-io.c | 5 | ||||
-rw-r--r-- | fiv.c | 4 |
2 files changed, 7 insertions, 2 deletions
@@ -1892,14 +1892,15 @@ open_resvg( resvg_options *opt = resvg_options_create(); resvg_options_load_system_fonts(opt); - resvg_options_set_resources_dir(opt, g_file_peek_path(base_file)); + if (base_file) + resvg_options_set_resources_dir(opt, g_file_peek_path(base_file)); if (ctx->screen_dpi) resvg_options_set_dpi(opt, ctx->screen_dpi); resvg_render_tree *tree = NULL; int err = resvg_parse_tree_from_data(data, len, opt, &tree); resvg_options_destroy(opt); - g_object_unref(base_file); + g_clear_object(&base_file); if (err != RESVG_OK) { set_error(error, load_resvg_error(err)); return NULL; @@ -634,7 +634,11 @@ switch_to_view(void) static gchar * parent_uri(GFile *child_file) { + // The empty URI results in a convenient dummy GFile implementation. GFile *parent = g_file_get_parent(child_file); + if (!parent) + return g_strdup(""); + gchar *parent_uri = g_file_get_uri(parent); g_object_unref(parent); return parent_uri; |