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

QString assertion failure using UTF-16 character in QJsonObject key

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • 6.8.4, 6.9.1, 6.10.0 FF
    • 6.8.1, 6.8.2
    • Core: Serialization
    • None
    • Windows 11
    • Windows
    • 54daec43a (dev), 8e94b67ba (6.9), d4a90a3f3 (6.8)

    Description

      In debug mode, I get an assertion failure when inserting valid data into a QJsonObject object.

      The message error is
      ASSERT: "lhs.size() == rhs.size()" in file C:\Users\qt\work\qt\qtbase\src\corelib\text\qstring.cpp. line 1395

      This is reproducible with these 3 lines of code and only if UTF-16 character is used for the JSON object key and if the second key is prior to the first one in alphabetical order.

      QJsonObject myObject;
      myObject.insert("k♭", "First key"); // key should contain UTF-16 character
      myObject.insert("a", "Second key");  // second key should be prior to first key in alphabetical order
      

      I checked the code and usually the size of lhs and rhs is checked before calling the function QtPrivate::equalStrings(QStringView lhs, QStringView rhs) (for example in comparesEqual function in file qstring.h at line 799)

      But this is not the case in function stringCompareElement(const QtCbor::Element &e, String s, QtCbor::Comparison mode) in file qcborvalue_p.h:365.

      Attachments

        1. main.cpp
          0.3 kB
          Stefania Pedrazzi
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            spedrazzi Stefania Pedrazzi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes