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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P0: Blocker
    • Resolution: Cannot Reproduce
    • Affects Version/s: 6.0.0 Alpha
    • Fix Version/s: None
    • Labels:
      None

      Description

      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.

        Attachments

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

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes