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

@@ -8,6 +8,7 @@
#include "json_inttypes.h"
#include "json_object.h"
#include "json_tokener.h"
int main()
{
@@ -33,5 +34,24 @@ int main()
retval=1;
}
json_object_put(string);
struct json_object *parsed_str = json_tokener_parse(expected);
if (parsed_str)
{
int parsed_len = json_object_get_string_len(parsed_str);
const char *parsed_cstr = json_object_get_string(parsed_str);
int ii;
printf("Re-parsed object string len=%d, chars=[", parsed_len);
for (ii = 0; ii < parsed_len ; ii++)
{
printf("%s%d", (ii ? ", " : ""), (int)parsed_cstr[ii]);
}
printf("]\n");
json_object_put(parsed_str);
}
else
{
printf("ERROR: failed to parse\n");
}
return retval;
}