Fix bug#71929

* 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)
This commit is contained in:
Po Lu 2024-07-09 22:00:39 +08:00
parent 8f96e0064f
commit 8350ebd22e
3 changed files with 14 additions and 14 deletions

View 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);

View 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.

View 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 */