diff --git a/lib/json.c b/lib/json.c index 6852ffd..2f6618b 100644 --- a/lib/json.c +++ b/lib/json.c @@ -331,11 +331,13 @@ static int handle_string_value_char (hcl_json_t* json, hcl_ooci_t c) /* convert the character to utf8 */ { hcl_bch_t bcsbuf[HCL_BCSIZE_MAX]; - hcl_oow_t ucslen = 1, bcslen; + hcl_oow_t ucslen, bcslen; + ucslen = 1; + bcslen = HCL_COUNTOF(bcsbuf); if (hcl_conv_uchars_to_bchars_with_cmgr(&json->state_stack->u.sv.acc, &ucslen, bcsbuf, &bcslen, hcl_json_getcmgr(json)) <= -1) { - hcl_json_seterrbfmt (json, HCL_EECERR, "unable to convert %jc", acc); + hcl_json_seterrbfmt (json, HCL_EECERR, "unable to convert %jc", json->state_stack->u.sv.acc); return -1; } else @@ -501,11 +503,12 @@ static int handle_character_value_char (hcl_json_t* json, hcl_ooci_t c) if (add_char_to_token(json, c) <= -1) return -1; } - if (json->tok.len >= 1) + if (json->tok.len > 1) { hcl_json_seterrbfmt (json, HCL_EINVAL, "too many characters in a character literal - %.*js", json->tok.len, json->tok.ptr); return -1; } + return ret; } diff --git a/lib/main-j.c b/lib/main-j.c index 1c4d529..bc052b8 100644 --- a/lib/main-j.c +++ b/lib/main-j.c @@ -320,8 +320,8 @@ int main (int argc, char* argv[]) json_xtn = hcl_json_getxtn(json); json_xtn->logmask = HCL_LOG_ALL_LEVELS | HCL_LOG_ALL_TYPES; - //p = "[ \"ab\\xab\\uC88B\\uC544\\uC6A9c\", \"kaden\", \"iron\", true, { \"null\": \"a\\1bc\", \"123\": \"AA20AA\", \"10\": -0.123, \"way\": '\\uC88B' } ]"; - p = "{ \"result\": \"SUCCESS\", \"message\": \"1 clients\", \"sessions\": [] }"; + p = "[ \"ab\\xab\\uC88B\\uC544\\uC6A9c\", \"kaden\", \"iron\", true, { \"null\": \"a\\1bc\", \"123\": \"AA20AA\", \"10\": -0.123, \"way\": '\\uC88A' } ]"; + /*p = "{ \"result\": \"SUCCESS\", \"message\": \"1 clients\", \"sessions\": [] }";*/ if (hcl_json_feed(json, p, strlen(p), &xlen) <= -1) {