mirror of
https://github.com/tmux/tmux.git
synced 2026-05-30 14:16:18 +00:00
Track which list (images or saved_images) each image is on so they can be
removed from the correct list when the total image count is reached. Fixes crash reported by xlabai at tencent dot com.
This commit is contained in:
7
image.c
7
image.c
@@ -53,14 +53,12 @@ image_log(struct image *im, const char* from, const char* fmt, ...)
|
|||||||
static void
|
static void
|
||||||
image_free(struct image *im)
|
image_free(struct image *im)
|
||||||
{
|
{
|
||||||
struct screen *s = im->s;
|
|
||||||
|
|
||||||
image_log(im, __func__, NULL);
|
image_log(im, __func__, NULL);
|
||||||
|
|
||||||
TAILQ_REMOVE(&all_images, im, all_entry);
|
TAILQ_REMOVE(&all_images, im, all_entry);
|
||||||
all_images_count--;
|
all_images_count--;
|
||||||
|
|
||||||
TAILQ_REMOVE(&s->images, im, entry);
|
TAILQ_REMOVE(im->list, im, entry);
|
||||||
sixel_free(im->data);
|
sixel_free(im->data);
|
||||||
free(im->fallback);
|
free(im->fallback);
|
||||||
free(im);
|
free(im);
|
||||||
@@ -137,7 +135,8 @@ image_store(struct screen *s, struct sixel_image *si)
|
|||||||
image_fallback(&im->fallback, im->sx, im->sy);
|
image_fallback(&im->fallback, im->sx, im->sy);
|
||||||
|
|
||||||
image_log(im, __func__, NULL);
|
image_log(im, __func__, NULL);
|
||||||
TAILQ_INSERT_TAIL(&s->images, im, entry);
|
im->list = &s->images;
|
||||||
|
TAILQ_INSERT_TAIL(im->list, im, entry);
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&all_images, im, all_entry);
|
TAILQ_INSERT_TAIL(&all_images, im, all_entry);
|
||||||
if (++all_images_count == MAX_IMAGE_COUNT)
|
if (++all_images_count == MAX_IMAGE_COUNT)
|
||||||
|
|||||||
10
screen.c
10
screen.c
@@ -658,6 +658,9 @@ void
|
|||||||
screen_alternate_on(struct screen *s, struct grid_cell *gc, int cursor)
|
screen_alternate_on(struct screen *s, struct grid_cell *gc, int cursor)
|
||||||
{
|
{
|
||||||
u_int sx, sy;
|
u_int sx, sy;
|
||||||
|
#ifdef ENABLE_SIXEL
|
||||||
|
struct image *im;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (SCREEN_IS_ALTERNATE(s))
|
if (SCREEN_IS_ALTERNATE(s))
|
||||||
return;
|
return;
|
||||||
@@ -674,6 +677,8 @@ screen_alternate_on(struct screen *s, struct grid_cell *gc, int cursor)
|
|||||||
|
|
||||||
#ifdef ENABLE_SIXEL
|
#ifdef ENABLE_SIXEL
|
||||||
TAILQ_CONCAT(&s->saved_images, &s->images, entry);
|
TAILQ_CONCAT(&s->saved_images, &s->images, entry);
|
||||||
|
TAILQ_FOREACH(im, &s->saved_images, entry)
|
||||||
|
im->list = &s->saved_images;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
grid_view_clear(s->grid, 0, 0, sx, sy, 8);
|
grid_view_clear(s->grid, 0, 0, sx, sy, 8);
|
||||||
@@ -687,6 +692,9 @@ void
|
|||||||
screen_alternate_off(struct screen *s, struct grid_cell *gc, int cursor)
|
screen_alternate_off(struct screen *s, struct grid_cell *gc, int cursor)
|
||||||
{
|
{
|
||||||
u_int sx = screen_size_x(s), sy = screen_size_y(s);
|
u_int sx = screen_size_x(s), sy = screen_size_y(s);
|
||||||
|
#ifdef ENABLE_SIXEL
|
||||||
|
struct image *im;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the current size is different, temporarily resize to the old size
|
* If the current size is different, temporarily resize to the old size
|
||||||
@@ -733,6 +741,8 @@ screen_alternate_off(struct screen *s, struct grid_cell *gc, int cursor)
|
|||||||
#ifdef ENABLE_SIXEL
|
#ifdef ENABLE_SIXEL
|
||||||
image_free_all(s);
|
image_free_all(s);
|
||||||
TAILQ_CONCAT(&s->images, &s->saved_images, entry);
|
TAILQ_CONCAT(&s->images, &s->saved_images, entry);
|
||||||
|
TAILQ_FOREACH(im, &s->images, entry)
|
||||||
|
im->list = &s->images;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (s->cx > screen_size_x(s) - 1)
|
if (s->cx > screen_size_x(s) - 1)
|
||||||
|
|||||||
4
tmux.h
4
tmux.h
@@ -971,8 +971,10 @@ struct image {
|
|||||||
u_int sx;
|
u_int sx;
|
||||||
u_int sy;
|
u_int sy;
|
||||||
|
|
||||||
TAILQ_ENTRY (image) all_entry;
|
struct images *list;
|
||||||
TAILQ_ENTRY (image) entry;
|
TAILQ_ENTRY (image) entry;
|
||||||
|
|
||||||
|
TAILQ_ENTRY (image) all_entry;
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(images, image);
|
TAILQ_HEAD(images, image);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user