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

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

    XMLWordPrintable

Details

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

    Description

      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.

      Attachments

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes