Fixed bug JsonObjectBase::getNestedTokenCount() that reads uninitialized token

This commit is contained in:
Benoit Blanchon
2014-07-14 15:52:26 +02:00
parent 39c185ae67
commit ccb97fc6e0

View File

@ -10,15 +10,15 @@ using namespace ArduinoJson::Parser;
int JsonObjectBase::getNestedTokenCount(jsmntok_t* token) int JsonObjectBase::getNestedTokenCount(jsmntok_t* token)
{ {
int end = token->end; int tokensToVisit = token->size;
int count = 0; int count = 0;
token++; while (tokensToVisit)
while (token->start < end)
{ {
token++;
count++; count++;
token++;
tokensToVisit--;
tokensToVisit += token->size;
} }
return count; return count;