all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Pip Cet <pipcet@gmail.com>
Cc: 36773@debbugs.gnu.org
Subject: bug#36773: 27.0.50; Accessing a cached SVG with eww can cause Emacs to crash
Date: Thu, 25 Jul 2019 14:37:26 -0700	[thread overview]
Message-ID: <3ffd73c9-3fa6-f5d6-63c5-21be090a332f@cs.ucla.edu> (raw)
In-Reply-To: <CAJw81dZ7yfg5ORAnECTM7HuO1RAc5TZgzgRFFfy0gbVAqx9bbw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 315 bytes --]

Thanks for writing those patches. The image.c patch is obviously needed to 
prevent a core dump, so I installed the attached variant of it (added a comment, 
changed a never-can-happen branch in obsolete code to an eassume). I assume the 
Elisp changes are good too, but I didn't check them so didn't install them.

[-- Attachment #2: 0001-Don-t-crash-when-parsing-bad-SVG-data.patch --]
[-- Type: text/x-patch, Size: 1491 bytes --]

From 2fbe24895bc621cb2ff1b9898c010eec288545f6 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 25 Jul 2019 14:29:22 -0700
Subject: [PATCH] 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.
---
 src/image.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/image.c b/src/image.c
index 355c849491..8cab860085 100644
--- a/src/image.c
+++ b/src/image.c
@@ -9530,10 +9530,13 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
   if (base_file)
     g_object_unref (base_file);
   g_object_unref (input_stream);
-  if (err) goto rsvg_error;
+
+  /* Check rsvg_handle too, to avoid librsvg 2.40.13 bug (Bug#36773#26).  */
+  if (!rsvg_handle || err) goto rsvg_error;
 #else
   /* Make a handle to a new rsvg object.  */
   rsvg_handle = rsvg_handle_new ();
+  eassume (rsvg_handle);
 
   /* Set base_uri for properly handling referenced images (via 'href').
      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,
   return 1;
 
  rsvg_error:
-  g_object_unref (rsvg_handle);
+  if (rsvg_handle)
+    g_object_unref (rsvg_handle);
   /* FIXME: Use error->message so the user knows what is the actual
      problem with the image.  */
   image_error ("Error parsing SVG image `%s'", img->spec);
-- 
2.17.1


      parent reply	other threads:[~2019-07-25 21:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23 16:40 bug#36773: 27.0.50; Accessing a cached SVG with eww can cause Emacs to crash adam plaice
2019-07-23 18:37 ` Pip Cet
2019-07-23 19:33   ` Adam Plaice
2019-07-23 20:06     ` Pip Cet
2019-07-23 21:13       ` Adam Plaice
2019-07-24 13:24         ` Pip Cet
2019-07-24 14:46           ` Eli Zaretskii
2019-07-24 18:28             ` Pip Cet
2019-07-24 19:11               ` Eli Zaretskii
2019-07-24 22:13                 ` Adam Plaice
2019-07-25 12:05                   ` Pip Cet
2019-07-25  9:38           ` Lars Ingebrigtsen
2019-07-25 11:51             ` Pip Cet
2019-07-25 12:55               ` Eli Zaretskii
2019-07-25 14:14                 ` Pip Cet
2019-07-25 22:14                   ` Adam Plaice
2019-07-27 10:58                   ` Eli Zaretskii
2019-07-25 17:09               ` Lars Ingebrigtsen
2019-07-25 21:37 ` Paul Eggert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ffd73c9-3fa6-f5d6-63c5-21be090a332f@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=36773@debbugs.gnu.org \
    --cc=pipcet@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.