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>
This commit is contained in:
parent
1ce52b0ddd
commit
8d169943eb
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user