emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 25a28ed4f7: Release resources in gif_load on errors


From: Lars Ingebrigtsen
Subject: master 25a28ed4f7: Release resources in gif_load on errors
Date: Tue, 12 Apr 2022 07:17:30 -0400 (EDT)

branch: master
commit 25a28ed4f7419154cd89b83a2ed907585db0de2b
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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.
---
 src/image.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/image.c b/src/image.c
index 3b3d1fc080..f56d02bf19 100644
--- a/src/image.c
+++ b/src/image.c
@@ -9249,11 +9249,13 @@ gif_load (struct frame *f, struct image *img)
   return true;
 
  gif_error:
-  if (!cache)
+  if (pixmap)
+    xfree (pixmap);
+  gif_close (gif, NULL);
+  if (cache)
     {
-      if (pixmap)
-       xfree (pixmap);
-      gif_close (gif, NULL);
+      cache->handle = NULL;
+      cache->temp = NULL;
     }
   return false;
 }
@@ -9501,9 +9503,6 @@ webp_load (struct frame *f, struct image *img)
   if (features.has_animation)
     {
       /* Animated image.  */
-      WebPData webp_data;
-      webp_data.bytes = contents;
-      webp_data.size = size;
       int timestamp;
 
       struct anim_cache* cache = anim_get_animation_cache (img->spec);
@@ -9524,6 +9523,10 @@ webp_load (struct frame *f, struct image *img)
          if (cache->handle)
            WebPAnimDecoderDelete (cache->handle);
 
+         WebPData webp_data;
+         webp_data.bytes = contents;
+         webp_data.size = size;
+
          /* Get the width/height of the total image.  */
          WebPDemuxer* demux = WebPDemux (&webp_data);
          cache->width = width = WebPDemuxGetI (demux, WEBP_FF_CANVAS_WIDTH);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]