Assertion with invalid JSON string

Bug #1331904 reported by Michi Henning
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libjsoncpp (Ubuntu)
New
Undecided
Unassigned

Bug Description

The following code parses the JSON string successfully, but then asserts where indicated:

    Json::Value root;
    Json::Reader reader;
    std::string s = R"(
        "a": "b"
    )";
    if (!reader.parse(s, root))
        abort();
    std::cerr << "parse OK" << std::endl;

    auto a = root["a"]; // Asserts at json_value.cpp:1136

The output is:

parse OK
src/lib_json/json_value.cpp:1136: Json::Value& Json::Value::resolveReference(const char*, bool): Assertion `type_ == nullValue || type_ == objectValue' failed.

parse() should report that the parse failed, but doesn't.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.