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

QJsonParseError members not initialized

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 5.12
    • Core: I/O
    • c6c84c8855835df43f3cb716972a59e9d7d2d03e (qt/qtbase/dev)

    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:

      https://scan3.coverity.com/reports.htm#v42553/p10113/fileInstanceId=32682065&defectInstanceId=8978161&mergedDefectId=263796

      Attachments

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              vhilshei Volker Hilsheimer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes