From 0f167c94c469dc340a63d18c1e8429a2ad161d8c Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Sat, 4 Jun 2016 15:36:46 +0200 Subject: [PATCH 1/3] avoid division by zero Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/75a96a2fb32389daf1517700ff124ade6eb946bf Author: Jacek Jendrzej Date: 2016-06-04 (Sat, 04 Jun 2016) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/audioplayer.cpp | 9 ++++++--- src/gui/pictureviewer.cpp | 7 +++++-- src/gui/upnpbrowser.cpp | 8 +++++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index 4d1e9ccc6..cb97df43e 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -1793,7 +1793,10 @@ void CAudioPlayerGui::paint() { if (m_show_playlist) { - m_liststart = (m_selected / m_listmaxshow) * m_listmaxshow; + unsigned int tmp_max = m_listmaxshow; + if(!tmp_max) + tmp_max = 1; + m_liststart = (m_selected / tmp_max) * m_listmaxshow; paintHead(); for (unsigned int count=0; countpaintBoxRel(m_x + m_width - 15, ypos, 15, sb, COL_MENUCONTENT_PLUS_1); - int sbc = ((m_playlist.size() - 1) / m_listmaxshow) + 1; - int sbs = (m_selected / m_listmaxshow); + int sbc = ((m_playlist.size() - 1) / tmp_max) + 1; + int sbs = (m_selected / tmp_max); if (sbc < 1) sbc = 1; diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index 40e5c3b28..9adbf5555 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -761,8 +761,11 @@ void CPictureViewerGui::paint() int sb = fheight* listmaxshow; frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); - int sbc= ((playlist.size()- 1)/ listmaxshow)+ 1; - int sbs= (selected/listmaxshow); + unsigned int tmp_max = listmaxshow; + if(!tmp_max) + tmp_max = 1; + int sbc= ((playlist.size()- 1)/ tmp_max)+ 1; + int sbs= (selected/tmp_max); if (sbc < 1) sbc = 1; diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index 649b22860..5baa6df67 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -965,9 +965,11 @@ void CUpnpBrowserGui::paintDevices() 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 = ((m_devices.size() - 1) / m_listmaxshow) + 1; - int sbs = ((m_selecteddevice) / m_listmaxshow); + unsigned int tmp_max = m_listmaxshow; + if(!tmp_max) + tmp_max = 1; + int sbc = ((m_devices.size() - 1) / tmp_max) + 1; + int sbs = ((m_selecteddevice) / tmp_max); m_frameBuffer->paintBoxRel(m_x + m_width - 13, ypos + 2 + sbs*(sb-4)/sbc, 11, (sb-4)/sbc, COL_MENUCONTENT_PLUS_3); From 3ea3a9b43b75c729c0e5ef88b4f7792ed646989c Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Sat, 4 Jun 2016 16:19:57 +0200 Subject: [PATCH 2/3] src/system/localize.cpp Undefined allocation of 0 bytes Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/eb2c84434aa0d2c81b6a2f6949c03595e36c5cc8 Author: Jacek Jendrzej Date: 2016-06-04 (Sat, 04 Jun 2016) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/system/localize.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/system/localize.cpp b/src/system/localize.cpp index 607f7b95f..63f562437 100644 --- a/src/system/localize.cpp +++ b/src/system/localize.cpp @@ -223,17 +223,18 @@ CLocaleManager::loadLocale_ret_t CLocaleManager::loadLocale(const char * const l fclose(fd); if(buf) free(buf); - char *_mem = (char *) realloc(*mem, memp - *mem); - if (_mem) { - if (_mem != *mem) { - // most likely doesn't happen - for(unsigned int i = 1; i < sizeof(locale_real_names)/sizeof(const char *); i++) - if (loadData[i] != locale_real_names[i]) - loadData[i] -= *mem - _mem; - *mem = _mem; + if(memp - *mem > 0){ + char *_mem = (char *) realloc(*mem, memp - *mem); + if (_mem) { + if (_mem != *mem) { + // most likely doesn't happen + for(unsigned int i = 1; i < sizeof(locale_real_names)/sizeof(const char *); i++) + if (loadData[i] != locale_real_names[i]) + loadData[i] -= *mem - _mem; + *mem = _mem; + } } } - for (unsigned j = 1; j < (sizeof(locale_real_names)/sizeof(const char *)); j++) if (loadData[j] == locale_real_names[j]) { From 6c3566e235f7ca9b17c1fa48a18b7b89196c3cc9 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Sat, 4 Jun 2016 17:21:18 +0200 Subject: [PATCH 3/3] avoid division by zero Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f6eb565ea3c1dc0248fd14c1fb8f5eea54b4bac3 Author: Jacek Jendrzej Date: 2016-06-04 (Sat, 04 Jun 2016) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/bookmarkmanager.cpp | 6 ++++-- src/gui/timerlist.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gui/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp index 92b4dd1e8..94fe00bfb 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -469,8 +469,10 @@ void CBookmarkManager::paint() int ypos = y+ theight; int sb = 2*fheight* listmaxshow; frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); - - int sbc= ((bookmarks.size()- 1)/ listmaxshow)+ 1; + unsigned int tmp_max = listmaxshow; + if(!tmp_max) + tmp_max = 1; + int sbc= ((bookmarks.size()- 1)/ tmp_max)+ 1; if (sbc < 1) sbc = 1; diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index e695a5a0f..fb8927463 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -881,8 +881,10 @@ void CTimerList::paint() int ypos = y+ theight; int sb = 2*fheight* listmaxshow; frameBuffer->paintBoxRel(x+ width- 15,ypos, 15, sb, COL_MENUCONTENT_PLUS_1); - - int sbc= ((timerlist.size()- 1)/ listmaxshow)+ 1; + unsigned int tmp_max = listmaxshow; + if(!tmp_max) + tmp_max = 1; + int sbc= ((timerlist.size()- 1)/ tmp_max)+ 1; frameBuffer->paintBoxRel(x+ width- 13, ypos+ 2+ page_nr * (sb-4)/sbc, 11, (sb-4)/sbc, COL_MENUCONTENT_PLUS_3, RADIUS_SMALL); }