Avoid overflow in text layout
Fixes oss-fuzz issue 34597. Fixes: QTBUG-94197 Pick-to: 6.2 6.1 5.15 Change-Id: Icabcd5a87b809b6a5ae0f1a696ec3b5dd906886b Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>bb10
parent
68b855c215
commit
e473d96e65
|
|
@ -1937,7 +1937,8 @@ void QTextLine::layout_helper(int maxGlyphs)
|
|||
|
||||
if (lbh.currentPosition >= eng->layoutData->string.length()
|
||||
|| isBreakableSpace
|
||||
|| attributes[lbh.currentPosition].lineBreak) {
|
||||
|| attributes[lbh.currentPosition].lineBreak
|
||||
|| lbh.tmpData.textWidth >= QFIXED_MAX) {
|
||||
sb_or_ws = true;
|
||||
break;
|
||||
} else if (attributes[lbh.currentPosition].graphemeBoundary) {
|
||||
|
|
|
|||
|
|
@ -1910,6 +1910,20 @@ void tst_QTextLayout::longText()
|
|||
QFontMetricsF fm(layout.font());
|
||||
QVERIFY(layout.maximumWidth() - fm.horizontalAdvance(' ') <= QFIXED_MAX);
|
||||
}
|
||||
|
||||
{
|
||||
QTextLayout layout(QString("AAAAAAAA").repeated(200000));
|
||||
layout.setCacheEnabled(true);
|
||||
layout.beginLayout();
|
||||
forever {
|
||||
QTextLine line = layout.createLine();
|
||||
if (!line.isValid())
|
||||
break;
|
||||
}
|
||||
layout.endLayout();
|
||||
QFontMetricsF fm(layout.font());
|
||||
QVERIFY(layout.maximumWidth() - fm.horizontalAdvance('A') <= QFIXED_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QTextLayout::widthOfTabs()
|
||||
|
|
|
|||
Loading…
Reference in New Issue