Fix issue #53 - ensure explicit length string are still NUL terminated, and fix json_tokener_parse() to work properly with embedded unicode \u0000 values in strings.

Adjust test_null to check for this case.
See also http://bugs.debian.org/687269
This commit is contained in:
Eric Haszlakiewicz
2012-12-09 16:32:11 -06:00
parent 7a4506d6df
commit 4e4af93d66
3 changed files with 23 additions and 2 deletions

View File

@@ -620,8 +620,9 @@ struct json_object* json_object_new_string_len(const char *s, int len)
if(!jso) return NULL;
jso->_delete = &json_object_string_delete;
jso->_to_json_string = &json_object_string_to_json_string;
jso->o.c_string.str = (char*)malloc(len);
jso->o.c_string.str = (char*)malloc(len + 1);
memcpy(jso->o.c_string.str, (void *)s, len);
jso->o.c_string.str[len] = '\0';
jso->o.c_string.len = len;
return jso;
}