Merge pull request #5382 from YayoRazo/fix/sixel-saved-images-uaf

fix(screen): free alternate-screen images on screen destroy
This commit is contained in:
Nicholas Marriott
2026-07-12 21:40:02 +01:00
committed by GitHub

View File

@@ -152,6 +152,10 @@ screen_reset_hyperlinks(struct screen *s)
void
screen_free(struct screen *s)
{
#ifdef ENABLE_SIXEL
struct image *im;
#endif
free(s->sel);
free(s->tabs);
free(s->path);
@@ -169,6 +173,14 @@ screen_free(struct screen *s)
screen_free_titles(s);
#ifdef ENABLE_SIXEL
/*
* Images saved when entering the alternate screen stay linked in the
* global list; move them back so they are freed and unlinked here, or
* a later eviction would write through this freed screen.
*/
TAILQ_CONCAT(&s->images, &s->saved_images, entry);
TAILQ_FOREACH(im, &s->images, entry)
im->list = &s->images;
image_free_all(s);
#endif
}