aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-04-12 13:17:14 +0200
committerLars Ingebrigtsen2022-04-12 13:17:14 +0200
commit25a28ed4f7419154cd89b83a2ed907585db0de2b (patch)
treebb924365cd4bd6c3ebe147667fb0d1d8a3ba6157 /src
parent3de2462da7306f3b342f6402dd0c0b185ac2741f (diff)
downloademacs-25a28ed4f7419154cd89b83a2ed907585db0de2b.tar.gz
emacs-25a28ed4f7419154cd89b83a2ed907585db0de2b.zip
Release resources in gif_load on errors
* src/image.c (webp_load): Clean up code slightly. (gif_load): Really release resources on GIF parsing errors.
Diffstat (limited to 'src')
-rw-r--r--src/image.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/image.c b/src/image.c
index 3b3d1fc080a..f56d02bf198 100644
--- a/src/image.c
+++ b/src/image.c
@@ -9249,11 +9249,13 @@ gif_load (struct frame *f, struct image *img)
9249 return true; 9249 return true;
9250 9250
9251 gif_error: 9251 gif_error:
9252 if (!cache) 9252 if (pixmap)
9253 xfree (pixmap);
9254 gif_close (gif, NULL);
9255 if (cache)
9253 { 9256 {
9254 if (pixmap) 9257 cache->handle = NULL;
9255 xfree (pixmap); 9258 cache->temp = NULL;
9256 gif_close (gif, NULL);
9257 } 9259 }
9258 return false; 9260 return false;
9259} 9261}
@@ -9501,9 +9503,6 @@ webp_load (struct frame *f, struct image *img)
9501 if (features.has_animation) 9503 if (features.has_animation)
9502 { 9504 {
9503 /* Animated image. */ 9505 /* Animated image. */
9504 WebPData webp_data;
9505 webp_data.bytes = contents;
9506 webp_data.size = size;
9507 int timestamp; 9506 int timestamp;
9508 9507
9509 struct anim_cache* cache = anim_get_animation_cache (img->spec); 9508 struct anim_cache* cache = anim_get_animation_cache (img->spec);
@@ -9524,6 +9523,10 @@ webp_load (struct frame *f, struct image *img)
9524 if (cache->handle) 9523 if (cache->handle)
9525 WebPAnimDecoderDelete (cache->handle); 9524 WebPAnimDecoderDelete (cache->handle);
9526 9525
9526 WebPData webp_data;
9527 webp_data.bytes = contents;
9528 webp_data.size = size;
9529
9527 /* Get the width/height of the total image. */ 9530 /* Get the width/height of the total image. */
9528 WebPDemuxer* demux = WebPDemux (&webp_data); 9531 WebPDemuxer* demux = WebPDemux (&webp_data);
9529 cache->width = width = WebPDemuxGetI (demux, WEBP_FF_CANVAS_WIDTH); 9532 cache->width = width = WebPDemuxGetI (demux, WEBP_FF_CANVAS_WIDTH);