summaryrefslogtreecommitdiff
path: root/json_object.c
diff options
context:
space:
mode:
authorEric Haszlakiewicz <erh+git@nimenees.com>2012-12-09 16:32:11 -0600
committerEric Haszlakiewicz <erh+git@nimenees.com>2012-12-09 16:32:11 -0600
commit4e4af93d667ae0d3cb9779f5a3c3f964cc9d7d81 (patch)
treef2e3dc1f7de1def9f360dd03cc7b075507b4b173 /json_object.c
parent7a4506d6df902001a4261358ed0e04f66ac092d7 (diff)
downloadjson-c-4e4af93d667ae0d3cb9779f5a3c3f964cc9d7d81.tar.gz
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
Diffstat (limited to 'json_object.c')
-rw-r--r--json_object.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/json_object.c b/json_object.c
index 5b60a06..a84785c 100644
--- a/json_object.c
+++ b/json_object.c
@@ -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;
}