changed to null-terminate the intermediate token all the time in json.c

This commit is contained in:
hyung-hwan 2018-04-25 16:12:59 +00:00
parent 687d633c15
commit 727f612b38

View File

@ -160,6 +160,7 @@ static HCL_INLINE int is_digitchar (hcl_ooci_t c)
static void clear_token (hcl_json_t* json)
{
json->tok.len = 0;
if (json->tok_capa > 0) json->tok.ptr[json->tok.len] = '\0';
}
static int add_char_to_token (hcl_json_t* json, hcl_ooch_t ch)
@ -178,6 +179,7 @@ static int add_char_to_token (hcl_json_t* json, hcl_ooch_t ch)
}
json->tok.ptr[json->tok.len++] = ch;
json->tok.ptr[json->tok.len] = '\0';
return 0;
}