/* Handle a 4-byte sequence, or two sequences if a surrogate pair */
while(1) {
- if(strchr(json_hex_chars, c)) {
+ if( c && strchr(json_hex_chars, c)) {
tok->ucs_char += ((unsigned int)hexdigit(c) << ((3-tok->st_pos++)*4));
if(tok->st_pos == 4) {
unsigned char unescaped_utf[4];
*/
got_hi_surrogate = tok->ucs_char;
/* Not at end, and the next two chars should be "\u" */
- if ((tok->char_offset+1 != len) &&
- (tok->char_offset+2 != len) &&
+ if ((len == -1 || len > (tok->char_offset + 2)) &&
+ // str[0] != '0' && // implied by json_hex_chars, above.
(str[1] == '\\') &&
(str[2] == 'u'))
{
printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
json_object_put(new_obj);
+ // Test with a "short" high surrogate
+ new_obj = json_tokener_parse("[9,'\\uDAD");
+ printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
+ json_object_put(new_obj);
+
new_obj = json_tokener_parse("null");
printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
json_object_put(new_obj);