mirror of
https://github.com/json-c/json-c.git
synced 2026-03-27 00:49:07 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user