summaryrefslogtreecommitdiffstats
path: root/src/corelib/codecs
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2018-12-12 08:00:55 +0100
committerDavid Schulz <david.schulz@qt.io>2018-12-13 05:36:03 +0000
commit9ce4260d232d94a9c902333e4b894fc0514d9e6d (patch)
tree6dd960c9a9f800b677dce9f946a2c4d69fdf2e93 /src/corelib/codecs
parenteaf4438b3511c8380b9b691b656a87a60e342e29 (diff)
QWindowsLocalCodec::convertToUnicode(): Fix remaining char conversion
Prevent passing a zero argument to the cbMultiByte parameter of MultiByteToWideChar. According to the documentation this will always fail. This is triggered when calling convertToUnicode with a state having remainingChars of one and a length of one. The remaining chars will be completed and the length will be reduced to zero before the actual convert. Adding an early return after the completion to prevent calling MultiByteToWideChar with the invalid zero argument. Fixes: QTCREATORBUG-21622 Change-Id: Ic6a433dd929e97b1681583cb1b9a347afaa9a09f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/codecs')
-rw-r--r--src/corelib/codecs/qwindowscodec.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/codecs/qwindowscodec.cpp b/src/corelib/codecs/qwindowscodec.cpp
index 813d3c8153..37e1183fb6 100644
--- a/src/corelib/codecs/qwindowscodec.cpp
+++ b/src/corelib/codecs/qwindowscodec.cpp
@@ -83,8 +83,12 @@ QString QWindowsLocalCodec::convertToUnicode(const char *chars, int length, Conv
len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
prev, 2, wc.data(), wc.length());
if (len) {
- prepend = true;
sp.append(QChar(wc[0]));
+ if (mblen == 1) {
+ state->remainingChars = 0;
+ return sp;
+ }
+ prepend = true;
mb++;
mblen--;
wc[0] = 0;