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

QStringConverter::encodingForData is modifying the data that was passed in

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P0: Blocker P0: Blocker
    • None
    • 6.0.0 Alpha
    • None

      In the initial Qt 6.0 Alpha release, the QStringConverter::encodingForData function was inserting a zero character somewhere at the start of the string:

      #include <QByteArray>
      #include <QDebug>
      #include <QStringConverter>
      
      int main()
      {
          const QByteArray bytes { "Foo bar baz" };
          qDebug() << "before:" << bytes;
          QStringConverter::encodingForData(bytes.constData(), bytes.size());
          qDebug() << "after :" << bytes;
      }
      

      output:

      before: "Foo bar baz"
      after : "Foo \x00""ar baz"
      

      See comment for updated version for the latest Qt 6.0 Alpha release, where the parameter changed to QByteArrayView, which now crashes on this example.

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

            laknoll Lars Knoll
            bjorn Thorbjørn Lindeijer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes