Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.9.6, 5.11.1
-
None
-
MacOs homebrew Qt 5.11.1
Gentoo Qt 5.9.6
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
- relates to
-
QTBUG-75324 QJsonObject bug
-
- Closed
-
For Gerrit Dashboard: QTBUG-69626 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
235373,4 | QJsonDocument: Make emptyObject an object | 5.11 | qt/qtbase | Status: MERGED | +2 | 0 |
235729,2 | QJsonDocument: Make emptyObject an object | 5.9 | qt/qtbase | Status: MERGED | +2 | 0 |