From ea17525b2a13595ea544485a25233ba35a6f9f3f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 31 Oct 2012 14:28:47 +0100 Subject: [PATCH] Window: sanitize position in set_position --- src/window.cc | 6 ++++++ src/window.hh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/window.cc b/src/window.cc index fd3be30a..1b74f341 100644 --- a/src/window.cc +++ b/src/window.cc @@ -66,6 +66,12 @@ void Window::update_display_buffer() m_display_buffer.optimize(); } +void Window::set_position(const DisplayCoord& position) +{ + m_position.line = std::max(0_line, position.line); + m_position.column = std::max(0_char, position.column); +} + void Window::set_dimensions(const DisplayCoord& dimensions) { m_dimensions = dimensions; diff --git a/src/window.hh b/src/window.hh index 79310ddb..866bb3fb 100644 --- a/src/window.hh +++ b/src/window.hh @@ -25,7 +25,7 @@ public: ~Window(); const DisplayCoord& position() const { return m_position; } - void set_position(const DisplayCoord& position) { m_position = position; } + void set_position(const DisplayCoord& position); const DisplayCoord& dimensions() const { return m_dimensions; } void set_dimensions(const DisplayCoord& dimensions);