neutrino: fix crashes on invalid fonts

with the latest fontrenderer fix, invalid fonts now can lead to
division by zero errors. fix the occurences I found.

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@43 e54a6e83-5905-42d5-8d5c-058d10e6a962


Origin commit data
------------------
Branch: ni/coolstream
Commit: 83d7657b9d
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2009-12-13 (Sun, 13 Dec 2009)



------------------
This commit was generated by Migit
This commit is contained in:
Stefan Seyfried
2009-12-13 12:25:38 +00:00
parent 7f4e240e1e
commit 622cb421a7
4 changed files with 10 additions and 1 deletions

View File

@@ -552,6 +552,8 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int
radius = dy; radius = dy;
if (radius > 540) if (radius > 540)
radius = 540; radius = 540;
if (radius < 1) /* dx or dy = 0... */
radius = 1; /* avoid div by zero below */
scf = (540 * MUL) / radius; scf = (540 * MUL) / radius;

View File

@@ -451,6 +451,8 @@ int CChannelList::show()
if(theight < PIC_H) theight = PIC_H; if(theight < PIC_H) theight = PIC_H;
fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(); fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight();
if (fheight == 0)
fheight = 1; /* avoid crash on invalid font */
listmaxshow = (height - theight - buttonHeight -0)/fheight; listmaxshow = (height - theight - buttonHeight -0)/fheight;
height = theight + buttonHeight + listmaxshow * fheight; height = theight + buttonHeight + listmaxshow * fheight;
//info_height = fheight + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight() + 10; //info_height = fheight + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight() + 10;

View File

@@ -386,6 +386,8 @@ void CFileBrowser::commonInit()
theight = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->getHeight(); theight = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->getHeight();
fheight = g_Font[SNeutrinoSettings::FONT_TYPE_FILEBROWSER_ITEM]->getHeight(); fheight = g_Font[SNeutrinoSettings::FONT_TYPE_FILEBROWSER_ITEM]->getHeight();
if (fheight == 0)
fheight = 1; /* avoid div by zero on invalid font */
foheight = 30; foheight = 30;
liststart = 0; liststart = 0;

View File

@@ -79,7 +79,10 @@ CHintBox::CHintBox(const neutrino_locale_t Caption, const char * const Text, con
else else
break; break;
} }
entries_per_page = ((height - theight) / fheight) - 1; if (fheight != 0)
entries_per_page = ((height - theight) / fheight) - 1;
else /* avoid division by zero */
entries_per_page = 1;
current_page = 0; current_page = 0;
unsigned int additional_width; unsigned int additional_width;