From 302649eca41692dce9cbabde9b866fa1886ce3a5 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 20 Oct 2013 02:54:46 +0200 Subject: [PATCH] CTextBox: ensure restore of background, if pixbuf exists This may prevent undefined behavior or even possible segfaults --- src/gui/widget/textbox.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui/widget/textbox.cpp b/src/gui/widget/textbox.cpp index 74ae8b9b7..556697723 100644 --- a/src/gui/widget/textbox.cpp +++ b/src/gui/widget/textbox.cpp @@ -525,13 +525,16 @@ void CTextBox::refreshText(void) //Paint Text Background if (m_nPaintBackground){ - if (m_bgpixbuf) + if (m_bgpixbuf){ delete[] m_bgpixbuf; - m_bgpixbuf = NULL; + m_bgpixbuf = NULL; + } frameBuffer->paintBoxRel(ax, ay, dx, dy, m_textBackgroundColor, m_nBgRadius, m_nBgRadiusType); } - else - frameBuffer->RestoreScreen(ax, ay, dx, dy, m_bgpixbuf); + else{ + if (m_bgpixbuf) + frameBuffer->RestoreScreen(ax, ay, dx, dy, m_bgpixbuf); + } if( m_nNrOfLines <= 0) return;