Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
5.4.1
-
None
-
Windows XP and wine after cross-compiling with MXE (http://mxe.cc/), but probably all other systems as well.
Description
This is similar to QTBUG-38496. Programs crash when trying to use QTextStream::readLine, Qt was built without QT_NO_TEXTCODEC, and no proper codecs are found (as seems to happen when building with (some versions of) icu). A minimal test case (assuming a file named "test.txt" exists):
#include <QtGui> #include <iostream> int main(int argc, char *argv[]) { QFile fin("test.txt"); if (!fin.open(QIODevice::ReadOnly | QIODevice::Text)) return 1; QTextStream ts(&fin); std::cout << qPrintable(ts.readLine()); return 0; }
In QTextStreamPrivate::fillReadBuffer(), if no codec is found, it is set to QTextCodec::codecForLocale() (line 451), which may return NULL. On line 472, this is used in codec->toUnicode(...) without checking if codec is NULL, thus crashing the application. I suspect there are other places where the same might happen, but I haven't investigated.
For a test program to check which codecs are found, see QTBUG-38496.