aboutsummaryrefslogtreecommitdiff
path: root/sixel.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-03-07 15:53:27 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-03-11 16:32:59 +0000
commitae86043780df36d4dce8f38effd5023c4605b4ec (patch)
tree0cbe4c5ee1f2e36fe95bc2709c2a8d142811c2c1 /sixel.c
parentgenerate-alt-random: sixel: pan/pad must not be 0 (diff)
sixel: decgri: handle a repeat count of 0, by ignoring it
Diffstat (limited to 'sixel.c')
-rw-r--r--sixel.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sixel.c b/sixel.c
index 7c83edf9..2c440a6d 100644
--- a/sixel.c
+++ b/sixel.c
@@ -862,6 +862,9 @@ resize_horizontally(struct terminal *term, int new_width)
int alloc_height = (height + 6 - 1) / 6 * 6;
+ xassert(new_width > 0);
+ xassert(alloc_height > 0);
+
/* Width (and thus stride) change - need to allocate a new buffer */
uint32_t *new_data = xmalloc(new_width * alloc_height * sizeof(uint32_t));
@@ -901,6 +904,9 @@ resize_vertically(struct terminal *term, int new_height)
int alloc_height = (new_height + 6 - 1) / 6 * 6;
+ xassert(width > 0);
+ xassert(new_height > 0);
+
uint32_t *new_data = realloc(
old_data, width * alloc_height * sizeof(uint32_t));
@@ -1167,11 +1173,14 @@ decgri(struct terminal *term, uint8_t c)
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o':
case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v':
case 'w': case 'x': case 'y': case 'z': case '{': case '|': case '}':
- case '~':
- sixel_add_many(term, c - 63, term->sixel.param);
+ case '~': {
+ unsigned count = term->sixel.param;
+ if (likely(count > 0))
+ sixel_add_many(term, c - 63, count);
term->sixel.state = SIXEL_DECSIXEL;
break;
}
+ }
}
static void