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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.2.1
    • Fix Version/s: 5.3.1
    • Component/s: Core: Locales (i18n)
    • Labels:
      None
    • Environment:
      Windows XP 32, MSVC 2010
    • Commits:
      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

          For Gerrit Dashboard: QTBUG-38316
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              thiago Thiago Macieira
              Reporter:
              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