aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-11-23 18:22:40 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-11-23 18:22:40 +0000
commit275f97381d585c09c446946d46fb13956fc4ed89 (patch)
treec3cb296051ca9b44952aa509b3769743b636be9c
parentfoot/footclient: add short options to all command line options (diff)
sixel: fix crash when an explicit sixel size had a height less than 6 pixels
-rw-r--r--CHANGELOG.md1
-rw-r--r--sixel.c5
2 files changed, 2 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 88a48699..093d526c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -102,6 +102,7 @@ means foot can be PGO:d in e.g. sandboxed build scripts. See
(https://codeberg.org/dnkl/foot/issues/210).
* Key mappings for key combinations with `alt`+`return`.
* `footclient` `-m` (`--maximized`) flag being ignored.
+* Crash with explicitly sized sixels with a height less than 6 pixels.
### Security
diff --git a/sixel.c b/sixel.c
index 68490dfa..46927d07 100644
--- a/sixel.c
+++ b/sixel.c
@@ -815,9 +815,6 @@ resize(struct terminal *term, int new_width, int new_height)
assert(alloc_new_height >= new_height);
assert(alloc_new_height - new_height < 6);
- assert(new_width >= old_width);
- assert(new_height >= old_height);
-
uint32_t *new_data = NULL;
if (new_width == old_width) {
@@ -838,7 +835,7 @@ resize(struct terminal *term, int new_width, int new_height)
new_data = xmalloc(alloc_new_width * alloc_new_height * sizeof(uint32_t));
/* Copy old rows, and initialize new columns to background color */
- for (int r = 0; r < old_height; r++) {
+ for (int r = 0; r < min(old_height, new_height); r++) {
memcpy(&new_data[r * new_width], &old_data[r * old_width], old_width * sizeof(uint32_t));
for (int c = old_width; c < new_width; c++)