mirror of
https://github.com/tmux/tmux.git
synced 2025-12-23 16:56:06 +00:00
Check image size against available screen size properly, GitHub issue 4739.
This commit is contained in:
@@ -2367,8 +2367,11 @@ screen_write_sixelimage(struct screen_write_ctx *ctx, struct sixel_image *si,
|
|||||||
u_int x, y, sx, sy, cx = s->cx, cy = s->cy, i, lines;
|
u_int x, y, sx, sy, cx = s->cx, cy = s->cy, i, lines;
|
||||||
struct sixel_image *new;
|
struct sixel_image *new;
|
||||||
|
|
||||||
|
if (screen_size_y(s) == 1)
|
||||||
|
return;
|
||||||
|
|
||||||
sixel_size_in_cells(si, &x, &y);
|
sixel_size_in_cells(si, &x, &y);
|
||||||
if (x > screen_size_x(s) || y > screen_size_y(s)) {
|
if (x > screen_size_x(s) || y > screen_size_y(s) - 1) {
|
||||||
if (x > screen_size_x(s) - cx)
|
if (x > screen_size_x(s) - cx)
|
||||||
sx = screen_size_x(s) - cx;
|
sx = screen_size_x(s) - cx;
|
||||||
else
|
else
|
||||||
@@ -2379,12 +2382,10 @@ screen_write_sixelimage(struct screen_write_ctx *ctx, struct sixel_image *si,
|
|||||||
sy = y;
|
sy = y;
|
||||||
new = sixel_scale(si, 0, 0, 0, y - sy, sx, sy, 1);
|
new = sixel_scale(si, 0, 0, 0, y - sy, sx, sy, 1);
|
||||||
sixel_free(si);
|
sixel_free(si);
|
||||||
si = new;
|
if (new == NULL)
|
||||||
|
|
||||||
/* Bail out if the image cannot be scaled. */
|
|
||||||
if (si == NULL)
|
|
||||||
return;
|
return;
|
||||||
sixel_size_in_cells(si, &x, &y);
|
sixel_size_in_cells(new, &x, &y);
|
||||||
|
si = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
sy = screen_size_y(s) - cy;
|
sy = screen_size_y(s) - cy;
|
||||||
|
|||||||
Reference in New Issue
Block a user