Fixes issue 221 (#222)

https://github.com/lemire/simdjson/issues/221
This commit is contained in:
Daniel Lemire
2019-07-29 10:07:07 -04:00
committed by ioioioio
parent eba02dc1b9
commit f76ee5e5ef
5 changed files with 9 additions and 5 deletions
+5 -3
View File
@@ -35,9 +35,11 @@ ParsedJson::ParsedJson(ParsedJson && p)
WARN_UNUSED
bool ParsedJson::allocateCapacity(size_t len, size_t maxdepth) {
if ((maxdepth == 0) || (len == 0)) {
std::cerr << "capacities must be non-zero " << std::endl;
return false;
if (maxdepth <= 0) {
maxdepth = 1; // don't let the user allocate nothing
}
if (len <= 0) {
len = 64; // allocating 0 bytes is wasteful.
}
if(len > SIMDJSON_MAXSIZE_BYTES) {
return false;