Skip to content

Commit

Permalink
Avoid memory error
Browse files Browse the repository at this point in the history
But simply use `.assign()` instead of the extra copy. (See comment from
@BillyDonhue at #580.)

fixes #578
closes #580
  • Loading branch information
cdunn2001 committed Aug 27, 2017
1 parent 9006194 commit 004270d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/lib_json/json_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ Reader::Reader(const Features& features)

bool
Reader::parse(const std::string& document, Value& root, bool collectComments) {
JSONCPP_STRING documentCopy(document.data(), document.data() + document.length());
std::swap(documentCopy, document_);
document_.assign(document.begin(), document.end());
const char* begin = document_.c_str();
const char* end = begin + document_.length();
return parse(begin, end, root, collectComments);
Expand Down

0 comments on commit 004270d

Please sign in to comment.