mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-09 14:13:28 +02:00
Avoid memory error
But simply use `.assign()` instead of the extra copy. (See comment from @BillyDonhue at #580.) fixes #578 closes #580
This commit is contained in:
@@ -103,8 +103,7 @@ Reader::Reader(const Features& features)
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
Reader::parse(const std::string& document, Value& root, bool collectComments) {
|
Reader::parse(const std::string& document, Value& root, bool collectComments) {
|
||||||
JSONCPP_STRING documentCopy(document.data(), document.data() + document.length());
|
document_.assign(document.begin(), document.end());
|
||||||
std::swap(documentCopy, document_);
|
|
||||||
const char* begin = document_.c_str();
|
const char* begin = document_.c_str();
|
||||||
const char* end = begin + document_.length();
|
const char* end = begin + document_.length();
|
||||||
return parse(begin, end, root, collectComments);
|
return parse(begin, end, root, collectComments);
|
||||||
|
Reference in New Issue
Block a user