]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug#71929
authorPo Lu <luangruo@yahoo.com>
Tue, 9 Jul 2024 14:00:39 +0000 (22:00 +0800)
committerEshel Yaron <me@eshelyaron.com>
Tue, 9 Jul 2024 17:51:07 +0000 (19:51 +0200)
* src/image.c (free_image_cache): Unconditionally release image
cache, as this function is only called with its existence
already established.

* src/xfaces.c (free_frame_faces): Clear FRAME_IMAGE_CACHE (f).
(bug#71929)

(cherry picked from commit 8350ebd22e983df5eb9ad33d427bd3d6a09ffe7f)

src/dispextern.h
src/image.c
src/xfaces.c

index 51dc354d37c1e6587ffc1a7edc9c0add2c857e2c..cc248a4472ecb324e233e6e977dda101398be5ee 100644 (file)
@@ -3653,7 +3653,7 @@ extern void x_kill_gs_process (Pixmap, struct frame *);
 extern Lisp_Object image_find_image_file (Lisp_Object);
 
 struct image_cache *make_image_cache (void);
-void free_image_cache (struct frame *);
+extern void free_image_cache (struct frame *);
 void clear_image_caches (Lisp_Object);
 void mark_image_cache (struct image_cache *);
 void image_prune_animation_caches (bool);
index 2945447b962e469046e8ed268f679e38de5de9ac..2ee2f3245be23649bdfbabd8afb64f3922d07ae8 100644 (file)
@@ -2304,23 +2304,18 @@ void
 free_image_cache (struct frame *f)
 {
   struct image_cache *c = FRAME_IMAGE_CACHE (f);
-  if (c)
-    {
-      ptrdiff_t i;
+  ptrdiff_t i;
 
-      /* Cache should not be referenced by any frame when freed.  */
-      eassert (c->refcount == 0);
+  /* Cache should not be referenced by any frame when freed.  */
+  eassert (c->refcount == 0);
 
-      for (i = 0; i < c->used; ++i)
-       free_image (f, c->images[i]);
-      xfree (c->images);
-      xfree (c->buckets);
-      xfree (c);
-      FRAME_IMAGE_CACHE (f) = NULL;
-    }
+  for (i = 0; i < c->used; ++i)
+    free_image (f, c->images[i]);
+  xfree (c->images);
+  xfree (c->buckets);
+  xfree (c);
 }
 
-
 /* Clear image cache of frame F.  FILTER=t means free all images.
    FILTER=nil means clear only images that haven't been
    displayed for some time.
index 188dd4778bcea53d101004cef2795990c4ea2f4b..684b6ccfac72db4fc5ac22fb1b7b77d8bd43eb12 100644 (file)
@@ -712,6 +712,11 @@ free_frame_faces (struct frame *f)
          --image_cache->refcount;
          if (image_cache->refcount == 0)
            free_image_cache (f);
+
+         /* The `image_cache' field must be emptied, in case references
+            to this dead frame should remain and be scanned by GC.
+            (bug#71929) */
+         FRAME_IMAGE_CACHE (f) = NULL;
        }
     }
 #endif /* HAVE_WINDOW_SYSTEM */