Permalink
Browse files

Fix possible divide by zero identified by Coverity

  • Loading branch information...
1 parent 46bcb72 commit 53c22345d7f00ad93924150a253c0d1bb0519f17 @stuartm stuartm committed May 10, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 mythtv/libs/libmythui/mythuitext.cpp
View
7 mythtv/libs/libmythui/mythuitext.cpp
@@ -601,8 +601,8 @@ bool MythUIText::GetNarrowWidth(const QStringList & paragraphs,
MythRect textrect(m_Area);
qreal height, last_line_width, lines;
int best_width, too_narrow, last_width = -1;
- int num_lines, line_height;
- int attempt;
+ int num_lines, line_height = 0;
+ int attempt = 0;
Qt::TextElideMode cutdown = m_Cutdown;
m_Cutdown = Qt::ElideNone;
@@ -621,6 +621,9 @@ bool MythUIText::GetNarrowWidth(const QStringList & paragraphs,
LayoutParagraphs(paragraphs, textoption, width, height,
min_rect, last_line_width, num_lines, false);
+ if (num_lines <= 0)
+ return false;
+
if (height > m_drawRect.height())
{
if (too_narrow < width)

0 comments on commit 53c2234

Please sign in to comment.