Skip to content

Commit a25b8df

Browse files
committed
Guard against out-of-bounds asserts in MythUIText::Layout().
1 parent 1203e7c commit a25b8df

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

mythtv/libs/libmythui/mythuitext.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -527,14 +527,24 @@ bool MythUIText::Layout(QString & paragraph, QTextLayout *layout, bool final,
527527
*/
528528
QFontMetrics fm(GetFontProperties()->face());
529529
int bearing;
530+
int position;
530531

531-
bearing = fm.leftBearing(m_CutMessage[last_line]);
532-
if (m_leftBearing > bearing)
533-
m_leftBearing = bearing;
534-
bearing = fm.rightBearing
535-
(m_CutMessage[last_line + line.textLength() - 1]);
536-
if (m_rightBearing > bearing)
537-
m_rightBearing = bearing;
532+
position = last_line;
533+
if (m_CutMessage.length() > position)
534+
{
535+
bearing = fm.leftBearing(m_CutMessage[position]);
536+
if (m_leftBearing > bearing)
537+
m_leftBearing = bearing;
538+
}
539+
540+
position = (last_line + line.textLength() - 1);
541+
if (m_CutMessage.length() > position && position >= 0)
542+
{
543+
bearing = fm.rightBearing
544+
(m_CutMessage[position]);
545+
if (m_rightBearing > bearing)
546+
m_rightBearing = bearing;
547+
}
538548
}
539549
}
540550

0 commit comments

Comments
 (0)