aboutsummaryrefslogtreecommitdiff
path: root/sixel.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-04-07 17:08:29 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-04-07 17:08:29 +0000
commit5f8a8951c77abec86f81b783a955d49cc9679faf (patch)
tree52f9ca51482144434ceaf7981309167bd262ff1f /sixel.c
parentsixel: sixel_fini(): free image data (diff)
sixel: unhook: tighten up the condition needed for us to free image data pre-maturely
Diffstat (limited to 'sixel.c')
-rw-r--r--sixel.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sixel.c b/sixel.c
index f4d917f4..0e8c58d5 100644
--- a/sixel.c
+++ b/sixel.c
@@ -727,11 +727,6 @@ sixel_unhook(struct terminal *term)
term->sixel.image.height = term->sixel.max_non_empty_row_no + 1;
}
- if (term->sixel.image.height == 0 || term->sixel.image.width == 0) {
- /* We won’t be emitting any sixels - free backing image */
- free(term->sixel.image.data);
- }
-
int pixel_row_idx = 0;
int pixel_rows_left = term->sixel.image.height;
const int stride = term->sixel.image.width * sizeof(uint32_t);
@@ -766,6 +761,11 @@ sixel_unhook(struct terminal *term)
int start_row = do_scroll ? term->grid->cursor.point.row : 0;
const int start_col = do_scroll ? term->grid->cursor.point.col : 0;
+ if (pixel_rows_left == 0 || rows_avail == 0) {
+ /* We won’t be emitting any sixels - free backing image */
+ free(term->sixel.image.data);
+ }
+
/* We do not allow sixels to cross the scrollback wrap-around, as
* this makes intersection calculations much more complicated */
while (pixel_rows_left > 0 && rows_avail > 0) {