summaryrefslogtreecommitdiff
path: root/src/image.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2022-09-13 17:12:40 +0300
committerEli Zaretskii <eliz@gnu.org>2022-09-13 17:12:40 +0300
commit48c562fb748623ed01385eaf215333a6c2edac80 (patch)
tree4636b8d5dae85feb752680855558be7758b76b30 /src/image.c
parent07c0e090bd17204bb1a7670716974c566a8ff6ae (diff)
downloademacs-48c562fb748623ed01385eaf215333a6c2edac80.tar.gz
emacs-48c562fb748623ed01385eaf215333a6c2edac80.tar.bz2
emacs-48c562fb748623ed01385eaf215333a6c2edac80.zip
; * src/image.c (svg_load_image): Another minor cleanup. (Bug#51104)
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/image.c b/src/image.c
index 52fdf861384..551da716434 100644
--- a/src/image.c
+++ b/src/image.c
@@ -11183,6 +11183,10 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
char *wrapped_contents = NULL;
ptrdiff_t wrapped_size;
+ bool empty_errmsg = true;
+ const char *errmsg = "";
+ ptrdiff_t errlen = 0;
+
#if LIBRSVG_CHECK_VERSION (2, 48, 0)
char *css = NULL;
#endif
@@ -11540,20 +11544,22 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
return true;
rsvg_error:
- if (!err || !err->message[0])
- image_error ("Error parsing SVG image");
- else
+ if (err && err->message[0])
{
- char *errmsg = err->message;
- ptrdiff_t errlen = strlen (errmsg);
-
+ errmsg = err->message;
+ errlen = strlen (errmsg);
/* Remove trailing whitespace from the error message text. It
has a newline at the end, and perhaps more whitespace. */
- while (c_isspace (errmsg[errlen - 1]))
+ while (errlen && c_isspace (errmsg[errlen - 1]))
errlen--;
- image_error ("Error parsing SVG image: %s", make_string (errmsg, errlen));
+ empty_errmsg = errlen == 0;
}
+ if (empty_errmsg)
+ image_error ("Error parsing SVG image");
+ else
+ image_error ("Error parsing SVG image: %s", make_string (errmsg, errlen));
+
if (err)
g_error_free (err);