Skip to content

jsoncpp - 0.10.7 - bool Reader::parse - bug for old C++ #1636

@pavel-pimenov

Description

@pavel-pimenov

bool Reader::parse(std::istream& sin, Value& root, bool collectComments) {
std::string doc;
std::getline(sin, doc, (char)EOF); // WRONG!
return parse(doc, root, collectComments);
}

Problem: Using EOF as a delimiter in std::getline() is wrong. EOF is a constant (typically -1) that's not a valid character for stream reading. This will cause undefined behavior.

EOF = 0xFF - CP1251 - char('я') - the last letter of the alphabet :)
error parse json

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions