summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Hindenburg <kurt.hindenburg@gmail.com>2012-07-20 02:34:01 (GMT)
committerKurt Hindenburg <kurt.hindenburg@gmail.com>2012-07-20 02:54:35 (GMT)
commit4ce0647eaae3cc1e486955232e9dc52c43538233 (patch)
tree24f6681aed54b2d1b073fe25df7345a940c4aa5e
parent8327db87ffac7a5e48792bc80e87a1fb16a74e30 (diff)
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. A better patch by Francesco Cecconi <francesco.cecconi@gmail.com> BUG: 303390 (cherry picked from commit 69b53c00ae53d6a066292d3f1a96599a75eff618)
-rw-r--r--src/TerminalCharacterDecoder.cpp7
1 files changed, 1 insertions, 6 deletions
diff --git a/src/TerminalCharacterDecoder.cpp b/src/TerminalCharacterDecoder.cpp
index eee51d6..b2b378f 100644
--- a/src/TerminalCharacterDecoder.cpp
+++ b/src/TerminalCharacterDecoder.cpp
@@ -123,13 +123,8 @@ 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 += stringWidth;
+ i += qMax(1, string_width(s));
}
}
else