diff --git a/src/driver/pictureviewer/pictureviewer.cpp b/src/driver/pictureviewer/pictureviewer.cpp index c13ce7251..7c81ef2ed 100644 --- a/src/driver/pictureviewer/pictureviewer.cpp +++ b/src/driver/pictureviewer/pictureviewer.cpp @@ -774,10 +774,11 @@ unsigned char * CPictureViewer::int_Resize(unsigned char *orgin, int ox, int oy, r+=q[0]; g+=q[1]; b+=q[2]; a+=q[3]; } } - p[0]= uint8_t(r/sq); - p[1]= uint8_t(g/sq); - p[2]= uint8_t(b/sq); - p[3]= uint8_t(a/sq); + int sq_tmp = sq ? sq : 1;//avoid division by zero + p[0]= uint8_t(r/sq_tmp); + p[1]= uint8_t(g/sq_tmp); + p[2]= uint8_t(b/sq_tmp); + p[3]= uint8_t(a/sq_tmp); } } }else @@ -796,9 +797,10 @@ unsigned char * CPictureViewer::int_Resize(unsigned char *orgin, int ox, int oy, r+=q[0]; g+=q[1]; b+=q[2]; } } - p[0]= uint8_t(r/sq); - p[1]= uint8_t(g/sq); - p[2]= uint8_t(b/sq); + int sq_tmp = sq ? sq : 1;//avoid division by zero + p[0]= uint8_t(r/sq_tmp); + p[1]= uint8_t(g/sq_tmp); + p[2]= uint8_t(b/sq_tmp); } } } diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 02dfe231c..ccc3dce1e 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -2161,9 +2161,9 @@ void CChannelList::paintBody() const int ypos = y+ theight; 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); - - int sbc= (((*chanlist).size()- 1)/ listmaxshow)+ 1; - const int sbs= (selected/listmaxshow); + unsigned int listmaxshow_tmp = listmaxshow ? listmaxshow : 1;//avoid division by zero + int sbc= (((*chanlist).size()- 1)/ listmaxshow_tmp)+ 1; + const int sbs= (selected/listmaxshow_tmp); if (sbc < 1) sbc = 1; diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index 43fc71852..649b22860 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -1137,9 +1137,9 @@ printf("CUpnpBrowserGui::paintItem:s selected %d max %d offset %d\n", selected, ypos = m_y + m_title_height + m_theight; int sb = m_fheight * m_listmaxshow; m_frameBuffer->paintBoxRel(m_x + m_width - 15, ypos, 15, sb, COL_MENUCONTENT_PLUS_1); - - int sbc = ((max + offset - 1) / m_listmaxshow) + 1; - int sbs = ((selected + offset) / m_listmaxshow); + unsigned int tmp = m_listmaxshow ? m_listmaxshow : 1;//avoid division by zero + int sbc = ((max + offset - 1) / tmp) + 1; + int sbs = ((selected + offset) / tmp); int sbh = 0; if ((sbc > 0) && (sbc > sb-4)) diff --git a/src/gui/widget/buttons.cpp b/src/gui/widget/buttons.cpp index 4134eb0a8..b054760cc 100644 --- a/src/gui/widget/buttons.cpp +++ b/src/gui/widget/buttons.cpp @@ -221,12 +221,15 @@ int paintButtons( const button_label_ext * const content, } if (spacing >= 0) - { /* add half of the inter-object space to the */ - spacing /= count_labels; /* left and right (this might break vertical */ - x_button += spacing / 2; /* alignment, but nobody is using this (yet) */ - } /* and I'm don't know how it should work. */ + { + int tmp = count_labels ? count_labels : 1;//avoid division by zero + /* add half of the inter-object space to the */ + spacing /= tmp; /* left and right (this might break vertical */ + x_button += spacing / 2; /* alignment, but nobody is using this (yet) */ + } /* and I'm don't know how it should work. */ else { + w_text = w_text ? w_text : 1; /* shorten captions relative to their length */ for (int i = 0; i < cnt; i++) fwidth[i] = (fwidth[i] * (w_text + spacing)) / w_text; /* spacing is negative...*/ @@ -410,8 +413,9 @@ int paintButtons( const int &x, else { /* shorten captions relative to their length */ + int tmp = w_text ? w_text : 1;//avoid division by zero for (i = 0; i < cnt; i++) - fwidth[i] = (fwidth[i] * (w_text + spacing)) / w_text; /* spacing is negative...*/ + fwidth[i] = (fwidth[i] * (w_text + spacing)) / tmp; /* spacing is negative...*/ spacing = 0; }