Closed
Description
Our valgrind tests, some of which use jsoncpp, detected an uninitialized value being used when creating a std::string
of a certain size and passing it into Reader::parse
. The std::string
, which we create with a string literal, has a size()
of 54 but a capacity()
of 63. After being passed into Reader::parse
, this code runs:
bool
Reader::parse(const std::string& document, Value& root, bool collectComments) {
JSONCPP_STRING documentCopy(document.data(), document.data() + document.capacity());
std::swap(documentCopy, document_);
This results in document_.size()
being 63; the Reader
is now operating on a string that is different than the one we passed in. Our valgrind errors suggest that the extra bytes here are not zero-initialized and are eventually read down the line in Reader::skipSpaces()
.
I believe the call to capacity()
in that code above should instead be a call to size()
.
Metadata
Metadata
Assignees
Labels
No labels