aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-06-27 11:18:54 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-06-27 11:18:54 +0000
commit37ceb65729beb221e92de8a8ae07c8f3d3e207b5 (patch)
tree95eead7eb5df2cd6a33f2422a969ede6825e7802
parentsixel: split: push front instead of back (diff)
sixel: split: make sure relative row/column values are bounded
-rw-r--r--sixel.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sixel.c b/sixel.c
index f04a8d7e..aaf5941e 100644
--- a/sixel.c
+++ b/sixel.c
@@ -168,10 +168,10 @@ static void
sixel_split(struct terminal *term, struct sixel *six,
int row, int col, int height, int width)
{
- int rel_above = max(row - six->pos.row, 0);
- int rel_below = min(row + height - six->pos.row, six->rows);
- int rel_left = max(col - six->pos.col, 0);
- int rel_right = min(col + width - six->pos.col, six->cols);
+ int rel_above = min(max(row - six->pos.row, 0), six->rows);
+ int rel_below = max(min(row + height - six->pos.row, six->rows), 0);
+ int rel_left = min(max(col - six->pos.col, 0), six->cols);
+ int rel_right = max(min(col + width - six->pos.col, six->cols), 0);
assert(rel_above >= 0);
assert(rel_below >= 0);