[vte] sixel: Be extra safe when advancing the scanline position



commit 90424aff47c0f49452185f419238e902515fe2b6
Author: Christian Persch <chpe src gnome org>
Date:   Tue Dec 1 22:05:58 2020 +0100

    sixel: Be extra safe when advancing the scanline position

 src/sixel-context.hh | 8 +++++---
 1 file 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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]