From 8e5ac76a2907a7a89b31ed562b5d086adaad5faf Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 20 May 2010 10:46:10 +0200 Subject: fix canonicalOrderHelper() for some corner case where string ends with sequence like HiS, LowS, NotS. in this case, if combiningClass(HiS, LowS) > combiningClass(NotS), then result will be invalid due to early exit on (p2 >= s.length()-1) Merge-request: 2393 Reviewed-by: Olivier Goffart --- src/corelib/tools/qchar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 29ecf10..c3e9f0e 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -1567,20 +1567,20 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in int p2 = pos+1; uint u1 = s.at(pos).unicode(); if (QChar(u1).isHighSurrogate()) { - ushort low = s.at(pos+1).unicode(); + ushort low = s.at(p2).unicode(); if (QChar(low).isLowSurrogate()) { - p2++; u1 = QChar::surrogateToUcs4(u1, low); if (p2 >= l) break; + ++p2; } } uint u2 = s.at(p2).unicode(); - if (QChar(u2).isHighSurrogate() && p2 < l-1) { + if (QChar(u2).isHighSurrogate() && p2 < l) { ushort low = s.at(p2+1).unicode(); if (QChar(low).isLowSurrogate()) { - p2++; u2 = QChar::surrogateToUcs4(u2, low); + ++p2; } } -- cgit v0.12