From 622cb421a70e16b58784718857e43e4baacb5542 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 13 Dec 2009 12:25:38 +0000 Subject: [PATCH] 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: https://github.com/neutrino-images/ni-neutrino/commit/83d7657b9dea871bc627ec0a1969533dc7bdc0ce Author: Stefan Seyfried Date: 2009-12-13 (Sun, 13 Dec 2009) ------------------ This commit was generated by Migit --- src/driver/framebuffer.cpp | 2 ++ src/gui/channellist.cpp | 2 ++ src/gui/filebrowser.cpp | 2 ++ src/gui/widget/hintbox.cpp | 5 ++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp index b57ec4723..1d8ad5adb 100644 --- a/src/driver/framebuffer.cpp +++ b/src/driver/framebuffer.cpp @@ -552,6 +552,8 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int radius = dy; if (radius > 540) radius = 540; + if (radius < 1) /* dx or dy = 0... */ + radius = 1; /* avoid div by zero below */ scf = (540 * MUL) / radius; diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index ae2e7948c..f73c5ada2 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -451,6 +451,8 @@ int CChannelList::show() if(theight < PIC_H) theight = PIC_H; fheight = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(); + if (fheight == 0) + fheight = 1; /* avoid crash on invalid font */ listmaxshow = (height - theight - buttonHeight -0)/fheight; height = theight + buttonHeight + listmaxshow * fheight; //info_height = fheight + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight() + 10; diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index 665adba2e..6215e9260 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -386,6 +386,8 @@ void CFileBrowser::commonInit() theight = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->getHeight(); fheight = g_Font[SNeutrinoSettings::FONT_TYPE_FILEBROWSER_ITEM]->getHeight(); + if (fheight == 0) + fheight = 1; /* avoid div by zero on invalid font */ foheight = 30; liststart = 0; diff --git a/src/gui/widget/hintbox.cpp b/src/gui/widget/hintbox.cpp index 8c2c57210..b20e4afa7 100644 --- a/src/gui/widget/hintbox.cpp +++ b/src/gui/widget/hintbox.cpp @@ -79,7 +79,10 @@ CHintBox::CHintBox(const neutrino_locale_t Caption, const char * const Text, con else 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; unsigned int additional_width;