From 459c12006017a21543c45e3142f35e3599c8ad79 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 19 Mar 2015 08:00:25 +0100 Subject: [PATCH] CTextBox: catching error if position has signed values Wrong position assignments can trigger crash. Prevent segfaults. Error log should indicate this. --- src/gui/widget/textbox.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 021c4cd95..bbe28d4a3 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -56,7 +56,7 @@ #endif #include - +#include #include "textbox.h" #include @@ -553,13 +553,13 @@ void CTextBox::refreshText(void) //bg variables int ax = m_cFrameTextRel.iX+m_cFrame.iX; - int ay = /*m_cFrameTextRel.iY+*/m_cFrame.iY; + int ay = m_cFrameTextRel.iY+m_cFrame.iY; int dx = m_cFrameTextRel.iWidth; int dy = m_cFrameTextRel.iHeight; //find changes bool has_changed = hasChanged(&ax, &ay, &dx, &dy); - + //destroy pixel buffer on changed property values if (has_changed){ if (m_bgpixbuf){ @@ -569,6 +569,12 @@ void CTextBox::refreshText(void) } } + //detect corrupt position values + if ((ax<=0) || (ay<=0)){ + dprintf(DEBUG_NORMAL, "\033[33m[CTextBox] [%s - %d] ERROR! position out of range: ax = %d, ay = %d, dx = %d, dy = %d\033[0m\n", __func__, __LINE__, ax, ay, dx, dy); + return; + } + //save screen only if no paint of background required if (!m_nPaintBackground && m_SaveScreen) { if (m_bgpixbuf == NULL){