summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2020-12-01 22:05:58 +0100
committerChristian Persch <chpe@src.gnome.org>2020-12-01 22:05:58 +0100
commit90424aff47c0f49452185f419238e902515fe2b6 (patch)
tree5729e7c23932fe5d55d0076e7552b391a9e2e672
parentcede6dac6bd281ebcf1e259b25079ceafb39ea0b (diff)
downloadvte-90424aff47c0f49452185f419238e902515fe2b6.tar.gz
sixel: Be extra safe when advancing the scanline position
-rw-r--r--src/sixel-context.hh8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/sixel-context.hh b/src/sixel-context.hh
index fa7d13e2..5cbcfcac 100644
--- a/src/sixel-context.hh
+++ b/src/sixel-context.hh
@@ -601,9 +601,11 @@ private:
m_scanline_mask |= sixel;
} else {
- /* If there are no bits to set, just advance the position */
- m_scanline_pos = std::min(m_scanline_end,
- m_scanline_pos + m_repeat_count * 6);
+ /* If there are no bits to set, just advance the position,
+ * making sure to guard against overflow.
+ */
+ m_scanline_pos = std::clamp(m_scanline_pos + m_repeat_count * 6,
+ m_scanline_begin, m_scanline_end);
}
m_repeat_count = 1;