aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2020-09-08 19:17:23 +0300
committerEli Zaretskii2020-09-08 19:17:23 +0300
commit366a97c980f068a3ed665d337d644ee58cd25ca0 (patch)
tree7ad02f21fd12b8c4a2630a30ee7f6dec714790fb /src
parent793871310599f8c75cf86bed97bdad70577cc5dd (diff)
downloademacs-366a97c980f068a3ed665d337d644ee58cd25ca0.tar.gz
emacs-366a97c980f068a3ed665d337d644ee58cd25ca0.zip
Avoid crashes when trying to load bad GIF files
* src/image.c (gif_load): Handle the case when GifErrorString returns NULL. (Bug#43281)
Diffstat (limited to 'src')
-rw-r--r--src/image.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/image.c b/src/image.c
index 56878bcb8cb..956fb1325ed 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8160,11 +8160,13 @@ gif_load (struct frame *f, struct image *img)
8160 if (gif == NULL) 8160 if (gif == NULL)
8161 { 8161 {
8162#if HAVE_GIFERRORSTRING 8162#if HAVE_GIFERRORSTRING
8163 image_error ("Cannot open `%s': %s", 8163 const char *errstr = GifErrorString (gif_err);
8164 file, build_string (GifErrorString (gif_err))); 8164 if (errstr)
8165#else 8165 image_error ("Cannot open `%s': %s", file, build_string (errstr));
8166 image_error ("Cannot open `%s'", file); 8166 else
8167#endif 8167#endif
8168 image_error ("Cannot open `%s'", file);
8169
8168 return 0; 8170 return 0;
8169 } 8171 }
8170 } 8172 }
@@ -8190,11 +8192,13 @@ gif_load (struct frame *f, struct image *img)
8190 if (!gif) 8192 if (!gif)
8191 { 8193 {
8192#if HAVE_GIFERRORSTRING 8194#if HAVE_GIFERRORSTRING
8193 image_error ("Cannot open memory source `%s': %s", 8195 const char *errstr = GifErrorString (gif_err);
8194 img->spec, build_string (GifErrorString (gif_err))); 8196 if (errstr)
8195#else 8197 image_error ("Cannot open memory source `%s': %s",
8196 image_error ("Cannot open memory source `%s'", img->spec); 8198 img->spec, build_string (errstr));
8199 else
8197#endif 8200#endif
8201 image_error ("Cannot open memory source `%s'", img->spec);
8198 return 0; 8202 return 0;
8199 } 8203 }
8200 } 8204 }
@@ -8474,9 +8478,9 @@ gif_load (struct frame *f, struct image *img)
8474 if (error_text) 8478 if (error_text)
8475 image_error ("Error closing `%s': %s", 8479 image_error ("Error closing `%s': %s",
8476 img->spec, build_string (error_text)); 8480 img->spec, build_string (error_text));
8477#else 8481 else
8478 image_error ("Error closing `%s'", img->spec);
8479#endif 8482#endif
8483 image_error ("Error closing `%s'", img->spec);
8480 } 8484 }
8481 8485
8482 /* Maybe fill in the background field while we have ximg handy. */ 8486 /* Maybe fill in the background field while we have ximg handy. */