Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-38316

QTextStreamPrivate::flushWriteBuffer() accesses nullptr during program termination.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.3.1
    • 5.2.1
    • Core: Locales (i18n)
    • None
    • Windows XP 32, MSVC 2010
    • f2a40fa07123748ece2fc93790345379f15ef07f

      During termination my program causes access violation trying to read at nullptr when I call

      QTextStream(stdout) << ... << endl;

      from within my global object's destructor.

      The problem is here:

      void QTextStreamPrivate::flushWriteBuffer()
      {
      ...
      if (!codec)}}
      codec = QTextCodec::codecForLocale();

      Since here you just assume codec is not nullptr and access it like this:

      QByteArray data = codec->fromUnicode(writeBuffer.data(), writeBuffer.size(), &writeConverterState);

      but QTextCodec::codecForLocale() may have returned nullptr if some internal Qt global data is already destroyed (destroyed before my global object) and if this is the case codec stays nullptr.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            thiago Thiago Macieira
            fnmdg gda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes