Răsfoiți Sursa

Don't add null terminator to each token.

Benoit Blanchon 12 ani în urmă
părinte
comite
0b485e95fa
2 a modificat fișierele cu 3 adăugiri și 6 ștergeri
  1. 3 0
      JsonObjectBase.cpp
  2. 0 6
      JsonParser.cpp

+ 3 - 0
JsonObjectBase.cpp

@@ -23,5 +23,8 @@ char* JsonObjectBase::getTokenString(jsmntok_t* token)
 	if (token->type != JSMN_PRIMITIVE && token->type != JSMN_STRING)
 		return 0;
 
+	// add null terminator to the string
+	json[token->end] = 0;
+
 	return json + token->start;
 }

+ 0 - 6
JsonParser.cpp

@@ -20,11 +20,5 @@ jsmntok_t* JsonParserBase::parse(char* jsonString)
 	if (JSMN_SUCCESS != jsmn_parse(&parser, jsonString, tokens, maxTokenCount))
 		return 0;
 
-	// Add null termination to each token
-	for (int i = 1; i < parser.toknext; i++)
-	{
-		jsonString[tokens[i].end] = 0;
-	}
-
 	return tokens;
 }