diff --git a/src/yajl/yajl_encode.c b/src/yajl/yajl_encode.c index 1a62aaf..e9e2aae 100644 --- a/src/yajl/yajl_encode.c +++ b/src/yajl/yajl_encode.c @@ -139,8 +139,8 @@ void yajl_string_decode(yajl_buf buf, const unsigned char * str, end+=3; /* check if this is a surrogate */ if ((codepoint & 0xFC00) == 0xD800) { - end++; - if (str[end] == '\\' && str[end + 1] == 'u') { + if (end + 2 < len && str[end + 1] == '\\' && str[end + 2] == 'u') { + end++; unsigned int surrogate = 0; hexToDigit(&surrogate, str + end + 2); codepoint =