diff options
| author | Paul Eggert | 2019-07-25 14:29:22 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-07-25 14:34:07 -0700 |
| commit | 263b9680f3204be994a90f3f2b73adaa81bec8dd (patch) | |
| tree | a695109bb07064e98f684e32fa1e32fa5be15fb9 /src/image.c | |
| parent | d8272ff755a4dcbef95cdda24b23154f47a953cb (diff) | |
| download | emacs-263b9680f3204be994a90f3f2b73adaa81bec8dd.tar.gz emacs-263b9680f3204be994a90f3f2b73adaa81bec8dd.zip | |
Don't crash when parsing bad SVG data
Derived from a patch by Pip Cet (Bug#36773#47).
* src/image.c (svg_load_image): Work around librsvg 2.40.13 bug.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/image.c b/src/image.c index 355c849491a..8cab860085f 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -9530,10 +9530,13 @@ svg_load_image (struct frame *f, struct image *img, char *contents, | |||
| 9530 | if (base_file) | 9530 | if (base_file) |
| 9531 | g_object_unref (base_file); | 9531 | g_object_unref (base_file); |
| 9532 | g_object_unref (input_stream); | 9532 | g_object_unref (input_stream); |
| 9533 | if (err) goto rsvg_error; | 9533 | |
| 9534 | /* Check rsvg_handle too, to avoid librsvg 2.40.13 bug (Bug#36773#26). */ | ||
| 9535 | if (!rsvg_handle || err) goto rsvg_error; | ||
| 9534 | #else | 9536 | #else |
| 9535 | /* Make a handle to a new rsvg object. */ | 9537 | /* Make a handle to a new rsvg object. */ |
| 9536 | rsvg_handle = rsvg_handle_new (); | 9538 | rsvg_handle = rsvg_handle_new (); |
| 9539 | eassume (rsvg_handle); | ||
| 9537 | 9540 | ||
| 9538 | /* Set base_uri for properly handling referenced images (via 'href'). | 9541 | /* Set base_uri for properly handling referenced images (via 'href'). |
| 9539 | See rsvg bug 596114 - "image refs are relative to curdir, not .svg file" | 9542 | See rsvg bug 596114 - "image refs are relative to curdir, not .svg file" |
| @@ -9654,7 +9657,8 @@ svg_load_image (struct frame *f, struct image *img, char *contents, | |||
| 9654 | return 1; | 9657 | return 1; |
| 9655 | 9658 | ||
| 9656 | rsvg_error: | 9659 | rsvg_error: |
| 9657 | g_object_unref (rsvg_handle); | 9660 | if (rsvg_handle) |
| 9661 | g_object_unref (rsvg_handle); | ||
| 9658 | /* FIXME: Use error->message so the user knows what is the actual | 9662 | /* FIXME: Use error->message so the user knows what is the actual |
| 9659 | problem with the image. */ | 9663 | problem with the image. */ |
| 9660 | image_error ("Error parsing SVG image `%s'", img->spec); | 9664 | image_error ("Error parsing SVG image `%s'", img->spec); |