mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
sixel: also set 'alloc_height', when short-cutting a resize operation
In some cases, a sixel may be resized vertically, while still having a zero-width. In this case, the resize operations are short-cutted, and no actual allocations are done. However, we forgot to set 'alloc_height' when doing so. As a result, the trimming code (when the sixel is "done"), trimmed away the entire sixel.
This commit is contained in:
parent
71ce17d977
commit
0ab05f4807
2 changed files with 8 additions and 2 deletions
|
|
@ -64,6 +64,9 @@
|
|||
|
||||
* Crash when printing double-width (or longer) characters to, or near,
|
||||
the last column, when auto-wrap (private mode 7) has been disabled.
|
||||
* Dynamically sized sixel being trimmed to nothing.
|
||||
|
||||
|
||||
### Security
|
||||
### Contributors
|
||||
|
||||
|
|
|
|||
7
sixel.c
7
sixel.c
|
|
@ -1400,7 +1400,7 @@ resize_horizontally(struct terminal *term, int new_width_mutable)
|
|||
new_width_mutable = term->sixel.max_width;
|
||||
}
|
||||
|
||||
if (unlikely(term->sixel.image.width == new_width_mutable))
|
||||
if (unlikely(term->sixel.image.width >= new_width_mutable))
|
||||
return;
|
||||
|
||||
const int sixel_row_height = 6 * term->sixel.pan;
|
||||
|
|
@ -1414,6 +1414,7 @@ resize_horizontally(struct terminal *term, int new_width_mutable)
|
|||
/* Lazy initialize height on first printed sixel */
|
||||
xassert(old_width == 0);
|
||||
term->sixel.image.height = height = sixel_row_height;
|
||||
term->sixel.image.alloc_height = sixel_row_height;
|
||||
} else
|
||||
height = term->sixel.image.height;
|
||||
|
||||
|
|
@ -1423,6 +1424,7 @@ resize_horizontally(struct terminal *term, int new_width_mutable)
|
|||
|
||||
int alloc_height = (height + sixel_row_height - 1) / sixel_row_height * sixel_row_height;
|
||||
|
||||
xassert(new_width >= old_width);
|
||||
xassert(new_width > 0);
|
||||
xassert(alloc_height > 0);
|
||||
|
||||
|
|
@ -1474,6 +1476,7 @@ resize_vertically(struct terminal *term, const int new_height)
|
|||
if (unlikely(width == 0)) {
|
||||
xassert(term->sixel.image.data == NULL);
|
||||
term->sixel.image.height = new_height;
|
||||
term->sixel.image.alloc_height = alloc_height;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1508,7 +1511,7 @@ resize(struct terminal *term, int new_width_mutable, int new_height_mutable)
|
|||
{
|
||||
LOG_DBG("resizing image: %dx%d -> %dx%d",
|
||||
term->sixel.image.width, term->sixel.image.height,
|
||||
new_width, new_height);
|
||||
new_width_mutable, new_height_mutable);
|
||||
|
||||
if (unlikely(new_width_mutable > term->sixel.max_width)) {
|
||||
LOG_WARN("maximum image width exceeded, truncating");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue