summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@theqtcompany.com>2016-04-12 13:39:18 +0200
committerEdward Welbourne <edward.welbourne@theqtcompany.com>2016-04-15 11:20:32 +0000
commit8d169943eb4421b6bf3165ff42d9444f282fb03c (patch)
tree7e069f0d2c088d5349d974f8a9ff32149b7152a2 /src
parent1ce52b0ddd71e7029f67fb91166783a0c09d25c6 (diff)
QWindowsLocalCodec::convertFromUnicode(): preclude stack overflow.
This method is called by QString::toLocal8Bit_helper(), so using QString::toLocal8Bit() on the input in an error message on failure to decode would be apt to recurse on the same data (if such an error ever arises). Furthermore, the qWarning()'s format string even claimed what it was displaying was in UTF-8. Fix by using native fprintf and UTF-16. Thanks to Frédéric Marchal for spotting this and checking that such errors aren't (at present) possible. Change-Id: I1ad441f2e3700bc01256d6c1718d404e27bce488 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/codecs/qwindowscodec.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/corelib/codecs/qwindowscodec.cpp b/src/corelib/codecs/qwindowscodec.cpp
index dded93ccb5..a7c6f72422 100644
--- a/src/corelib/codecs/qwindowscodec.cpp
+++ b/src/corelib/codecs/qwindowscodec.cpp
@@ -208,10 +208,12 @@ QByteArray QWindowsLocalCodec::convertFromUnicode(const QChar *ch, int uclen, Co
0, 0, 0, &used_def));
// and try again...
} else {
+ // Fail. Probably can't happen in fact (dwFlags is 0).
#ifndef QT_NO_DEBUG
- // Fail.
- qWarning("WideCharToMultiByte: Cannot convert multibyte text (error %d): %s (UTF-8)",
- r, QString(ch, uclen).toLocal8Bit().data());
+ // Can't use qWarning(), as it'll recurse to handle %ls
+ fprintf(stderr,
+ "WideCharToMultiByte: Cannot convert multibyte text (error %d): %ls\n",
+ r, reinterpret_cast<const wchar_t*>(QString(ch, uclen).utf16()));
#endif
break;
}