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

QJsonObject memory corruption

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.9.7, 5.11.2
    • 5.9.6, 5.11.1
    • Core: Other
    • None
    • MacOs homebrew Qt 5.11.1
      Gentoo Qt 5.9.6
    • Linux/X11, macOS

    Description

      Creating an empty object in an object, retrieving it for modification creates a memory corruption.

      The following code reproduces will randomly segfault (or display a corrupted item):

      #include <QJsonObject>
      #include <QDebug>
      
      int main() {
        QJsonObject parent;
        QJsonObject child;
      
        parent["child"] = child;
        child = parent["child"].toObject();
        // here we should have { "child": { } }
      
        child["test"] = "test";
        parent.insert("child", child);
        // here we should have { "child": { "test" : "test" } }
      
        qDebug() << parent;
      }

      Note: test fails only if child is an empty object when inserted
      Note: test fails only if child is retrieved from parent before being modified
      Note: commenting-out Data::compact code in qjson.cpp removes the issue (seems to be related to is_object flag)

      Is there any incorrect use of QJsonObject in the above code ?

      Attachments

        Issue Links

          Activity

            People

              juri.valdmann Jüri Valdmann (Inactive)
              fargies Sylvain Fargier
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: