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