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

Regression: UTF-32 codec fails on assert when fromUnicode() is called

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.2.1, 6.3.0 Alpha
    • 6.2.0
    • Core: Other
    • None
    • Linux/X11
    • 333b40a12e82edb44ee472d7b95e533a99bb32d0 (qt/qtbase/dev) 5c5f6b453d35f2d10e1448ba5302fe1c705f2c35 (qt/qtbase/6.2)

    Description

      Run the following example:

      #include <QDebug>
      #include <QFile>
      #include <QTextCodec>
      
      int main(int argc, char *argv[])
      {
          QTextCodec *codec = QTextCodec::codecForName("UTF-32");
          if (!codec) {
              qDebug() << "Could not find codec for UTF-32";
              return 0;
          }
          QFile file("dialog.ui");
          if (!file.open(QIODevice::ReadOnly)) {
              qDebug() << "Can't open input file.";
              return 0;
          }
          const QByteArray data = file.readAll();
          file.close();
      
          qDebug() << "About to transform";
          const QString str = codec->toUnicode(data);
          const QByteArray newData = codec->fromUnicode(str);
          qDebug() << "All went fine";
          return 0;
      }
      

      and place the attached dialog.ui in the executable directory. It aborts on a call to fromUnicode() with the following message:

      ASSERT: "end - ba.constData() == length" in file /home/jarek/dev/qt-62/qtbase/src/corelib/text/qstringconverter.cpp, line 1030
      

      Please note that the dialog.ui file has some strange encoding (file taken from QTCREATORBUG-26028 task). This code is running fine with Qt 5.15.

      Most probably the issue was introduced in b1d8ce32cd4dc7dc021aa9f0c05048753f04dd6c

      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
              jkobus Jarek Kobus
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes