Commit 5ae5bc50 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
This should prevent the crashes; not sure if there is a better way.

CCBUG: 303390
parent 57994c1d
......@@ -24,6 +24,7 @@
// Qt
#include <QtCore/QTextStream>
#include <KDebug>
// Konsole
#include "konsole_wcwidth.h"
......@@ -113,8 +114,13 @@ void PlainTextDecoder::decodeLine(const Character* const characters, int count,
const ushort* chars = ExtendedCharTable::instance.lookupExtendedChar(characters[i].character, extendedCharLength);
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) {
i += string_width(s);
i += stringWidth;
} else {
// All characters which appear before the last real character are
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment