From a33086568bc338438353eb52fe09bb4569675e86 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 29 May 2013 15:33:21 +0200 Subject: [PATCH] neutrino: fix possible div-by-zero in scrollbar calculation --- src/gui/audioplayer.cpp | 2 ++ src/gui/bedit/bouqueteditor_bouquets.cpp | 3 +++ src/gui/bedit/bouqueteditor_channels.cpp | 3 +++ src/gui/bookmarkmanager.cpp | 3 +++ src/gui/bouquetlist.cpp | 2 +- src/gui/channellist.cpp | 4 +++- src/gui/epgview.cpp | 2 ++ src/gui/eventlist.cpp | 3 +++ src/gui/filebrowser.cpp | 2 ++ src/gui/pictureviewer.cpp | 3 +++ src/gui/widget/listbox.cpp | 3 +++ 11 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index 4ccd13961..6c0a5043b 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -1874,6 +1874,8 @@ void CAudioPlayerGui::paint() int sbc = ((m_playlist.size() - 1) / m_listmaxshow) + 1; int sbs = (m_selected / m_listmaxshow); + if (sbc < 1) + sbc = 1; m_frameBuffer->paintBoxRel(m_x + m_width - 13, ypos + 2 + sbs*(sb-4)/sbc , 11, (sb-4)/sbc, COL_MENUCONTENT_PLUS_3, RADIUS_SMALL); } diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index bd772b241..4c4343d3b 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -121,6 +121,9 @@ void CBEBouquetWidget::paint() frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); int sbc= ((Bouquets->size()- 1)/ listmaxshow)+ 1; + if (sbc < 1) + sbc = 1; + float sbh= (sb- 4)/ sbc; int sbs= (selected/listmaxshow); diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp index 15fcada16..b146a7b78 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -160,6 +160,9 @@ void CBEChannelWidget::paint() frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); int sbc= ((Channels->size()- 1)/ listmaxshow)+ 1; + if (sbc < 1) + sbc = 1; + float sbh= (sb- 4)/ sbc; int sbs= (selected/listmaxshow); diff --git a/src/gui/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp index 05bbabd04..7bc6ec861 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -476,6 +476,9 @@ void CBookmarkManager::paint() frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); int sbc= ((bookmarks.size()- 1)/ listmaxshow)+ 1; + if (sbc < 1) + sbc = 1; + float sbh= (sb- 4)/ sbc; frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ int(page_nr * sbh) , 11, int(sbh), COL_MENUCONTENT_PLUS_3); diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp index cf5d5ccc6..8c46a2982 100644 --- a/src/gui/bouquetlist.cpp +++ b/src/gui/bouquetlist.cpp @@ -615,7 +615,7 @@ void CBouquetList::paint() int sb = fheight* listmaxshow; frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); - int sbc= ((bsize - 1)/ listmaxshow)+ 1; + int sbc= ((bsize - 1)/ listmaxshow)+ 1; /* bsize is > 0, so sbc is also > 0 */ float sbh= (sb - 4)/ sbc; int sbs= (selected/listmaxshow); diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 02be6b5c1..f7d86ca4a 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -2123,8 +2123,10 @@ void CChannelList::paint() const int sb = height - theight - footerHeight; // paint scrollbar over full height of main box frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); - const int sbc= ((chanlist.size()- 1)/ listmaxshow)+ 1; + int sbc= ((chanlist.size()- 1)/ listmaxshow)+ 1; const int sbs= (selected/listmaxshow); + if (sbc < 1) + sbc = 1; frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs*(sb-4)/sbc, 11, (sb-4)/sbc, COL_MENUCONTENT_PLUS_3); showChannelLogo(); diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 78e78ba6e..de5bf35a4 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -263,6 +263,8 @@ void CEpgData::showText( int startPos, int ypos ) int sbc = ((textSize - 1)/ medlinecount) + 1; int sbs= (startPos+ 1)/ medlinecount; + if (sbc < 1) + sbc = 1; frameBuffer->paintBoxRel(sx+ ox- 15, ypos, 15, sb, COL_MENUCONTENT_PLUS_1); // scrollbar bg frameBuffer->paintBoxRel(sx+ ox- 13, ypos+ 2+ sbs*(sb-4)/sbc , 11, (sb-4)/sbc, COL_MENUCONTENT_PLUS_3); // scrollbar } diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index ca9b314b1..fcd232e63 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -912,6 +912,9 @@ void CNeutrinoEventList::paint(t_channel_id channel_id) frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); int sbc= ((evtlist.size()- 1)/ listmaxshow)+ 1; + if (sbc < 1) + sbc = 1; + float sbh= (sb- 4)/ sbc; int sbs= (selected/listmaxshow); diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index 5ae161b7a..b6aacabbd 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -1523,6 +1523,8 @@ void CFileBrowser::paint() int sbc= ((filelist.size()- 1)/ listmaxshow)+ 1; int sbs= (selected/listmaxshow); + if (sbc < 1) + sbc = 1; frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ sbs*(sb-4)/sbc, 11, (sb-4)/sbc, COL_MENUCONTENT_PLUS_3, RADIUS_SMALL); } diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index 0f4d3b98b..35175ea09 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -754,6 +754,9 @@ void CPictureViewerGui::paint() frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); int sbc= ((playlist.size()- 1)/ listmaxshow)+ 1; + if (sbc < 1) + sbc = 1; + float sbh= (sb- 4)/ sbc; int sbs= (selected/listmaxshow); diff --git a/src/gui/widget/listbox.cpp b/src/gui/widget/listbox.cpp index 13b0ca223..9e057e72a 100644 --- a/src/gui/widget/listbox.cpp +++ b/src/gui/widget/listbox.cpp @@ -70,6 +70,9 @@ void CListBox::paint() frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); int sbc= ((getItemCount()- 1)/ listmaxshow)+ 1; + if (sbc < 1) + sbc = 1; + float sbh= (sb- 4)/ sbc; int sbs= (selected/listmaxshow);