Don't crash on orphan URIs
This commit is contained in:
parent
e6341e59bb
commit
4927c8c692
3
fiv-io.c
3
fiv-io.c
|
@ -1892,6 +1892,7 @@ open_resvg(
|
||||||
|
|
||||||
resvg_options *opt = resvg_options_create();
|
resvg_options *opt = resvg_options_create();
|
||||||
resvg_options_load_system_fonts(opt);
|
resvg_options_load_system_fonts(opt);
|
||||||
|
if (base_file)
|
||||||
resvg_options_set_resources_dir(opt, g_file_peek_path(base_file));
|
resvg_options_set_resources_dir(opt, g_file_peek_path(base_file));
|
||||||
if (ctx->screen_dpi)
|
if (ctx->screen_dpi)
|
||||||
resvg_options_set_dpi(opt, ctx->screen_dpi);
|
resvg_options_set_dpi(opt, ctx->screen_dpi);
|
||||||
|
@ -1899,7 +1900,7 @@ open_resvg(
|
||||||
resvg_render_tree *tree = NULL;
|
resvg_render_tree *tree = NULL;
|
||||||
int err = resvg_parse_tree_from_data(data, len, opt, &tree);
|
int err = resvg_parse_tree_from_data(data, len, opt, &tree);
|
||||||
resvg_options_destroy(opt);
|
resvg_options_destroy(opt);
|
||||||
g_object_unref(base_file);
|
g_clear_object(&base_file);
|
||||||
if (err != RESVG_OK) {
|
if (err != RESVG_OK) {
|
||||||
set_error(error, load_resvg_error(err));
|
set_error(error, load_resvg_error(err));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
4
fiv.c
4
fiv.c
|
@ -634,7 +634,11 @@ switch_to_view(void)
|
||||||
static gchar *
|
static gchar *
|
||||||
parent_uri(GFile *child_file)
|
parent_uri(GFile *child_file)
|
||||||
{
|
{
|
||||||
|
// The empty URI results in a convenient dummy GFile implementation.
|
||||||
GFile *parent = g_file_get_parent(child_file);
|
GFile *parent = g_file_get_parent(child_file);
|
||||||
|
if (!parent)
|
||||||
|
return g_strdup("");
|
||||||
|
|
||||||
gchar *parent_uri = g_file_get_uri(parent);
|
gchar *parent_uri = g_file_get_uri(parent);
|
||||||
g_object_unref(parent);
|
g_object_unref(parent);
|
||||||
return parent_uri;
|
return parent_uri;
|
||||||
|
|
Loading…
Reference in New Issue