Skip to content
Snippets Groups Projects
Commit f04bd15b authored by Kurt Hindenburg's avatar Kurt Hindenburg
Browse files

prevent crashing when selecting invalid unicode character.

Konsole goes into an infinite loop and will eventually crash due to
memory.  On an invalid unicode char the width is 0 so the for loop never
exits.
This should prevent the crashes; not sure if there is a better way.

CCBUG: 303390
(cherry picked from commit 5ae5bc50)
parent cc723381
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@
// Qt
#include <QtCore/QTextStream>
#include <KDebug>
// KDE
#include <KDebug>
......@@ -123,8 +124,13 @@ void PlainTextDecoder::decodeLine(const Character* const characters, int count,
if (chars)
{
const QString s = QString::fromUtf16(chars, extendedCharLength);
const int stringWidth = string_width(s);
// Infinite loop here if i is not incremented bko 303390
if (stringWidth < 1) {
break;
}
plainText.append(s);
i += string_width(s);
i += stringWidth;
}
}
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment