mirror of
https://github.com/nlohmann/json.git
synced 2024-11-24 06:29:03 +08:00
- memory problem
This commit is contained in:
parent
61461ec456
commit
abad903f31
@ -591,11 +591,11 @@ JSON::parser::parser(std::string& s) : _pos(0) {
|
|||||||
JSON::parser::parser(std::istream& _is) : _pos(0) {
|
JSON::parser::parser(std::istream& _is) : _pos(0) {
|
||||||
// determine length of input stream
|
// determine length of input stream
|
||||||
_is.seekg(0, std::ios::end);
|
_is.seekg(0, std::ios::end);
|
||||||
std::streampos length = _is.tellg();
|
size_t length = _is.tellg();
|
||||||
_is.seekg(0, std::ios::beg);
|
_is.seekg(0, std::ios::beg);
|
||||||
|
|
||||||
// copy stream to buffer
|
// copy stream to buffer
|
||||||
_buffer = new char[length];
|
_buffer = new char[length + 1];
|
||||||
_is.read(_buffer, length);
|
_is.read(_buffer, length);
|
||||||
|
|
||||||
// read first character
|
// read first character
|
||||||
|
Loading…
Reference in New Issue
Block a user