Details
Description
QJsonParseError has no constructor, and the error and offset members are not initialized in the declaration.
In the example examples/corelib/serialization/convert/jsonconverter.cpp, the JsonConverter::loadFile function instantiates an object and operates on it. However, the error object is only initialized conditionally by passing it as an out-parameter into QJsonDocument::fromJson. Static analysis shows that there are execution paths that end up with error.error being checked without any of the calls to QJsonDocument::fromJson initializing it.
Either the example needs to explicitly initialize the members of the error object, or QJsonParseError should do that implicitly. Since we try to make things simple with Qt, initializing those members implicitly is probably the better option.
For Coverity report, see:
Attachments
For Gerrit Dashboard: QTBUG-83880 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
298792,3 | Initialize data members of QJsonParseError | dev | qt/qtbase | Status: MERGED | +2 | 0 |