Browse Source

fix crash when svg file not found

master v0.1.2
Alexandros Theodotou 2 years ago
parent
commit
6797b593cb
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 2
      src/rsvg.c
  2. 1
      tests/meson.build
  3. 11
      tests/rsvg.c

2
src/rsvg.c

@ -44,7 +44,7 @@ ztk_rsvg_load_svg ( @@ -44,7 +44,7 @@ ztk_rsvg_load_svg (
{
ztk_error (
"An error occurred parsing the SVG file at "
"%s: %s", abs_path);
"%s: %s", abs_path, err->message);
g_object_unref (file);
return NULL;
}

1
tests/meson.build

@ -48,4 +48,5 @@ if get_option('enable_rsvg') @@ -48,4 +48,5 @@ if get_option('enable_rsvg')
test ('rsvg_test', e,
args: join_paths(
meson.current_source_dir(), 'test.svg'))
test ('rsvg_test_invalid', e, args: 'invalid')
endif

11
tests/rsvg.c

@ -26,7 +26,16 @@ int main ( @@ -26,7 +26,16 @@ int main (
{
ZtkRsvgHandle * handle =
ztk_rsvg_load_svg (argv[1]);
ztk_assert (handle);
if (strcmp (argv[1], "invalid"))
{
ztk_assert (handle);
}
else
{
ztk_assert (!handle);
return 0;
}
int width =
ztk_rsvg_get_width (handle);

Loading…
Cancel
Save