Fix heap-buffer-overflow in ecma_builtin_json_quote (#4143)

Fixes #4129.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
This commit is contained in:
Csaba Osztrogonác
2020-08-18 13:56:01 +02:00
committed by GitHub
parent d9cb2c60f2
commit b828d1c15f
2 changed files with 23 additions and 4 deletions
@@ -898,11 +898,15 @@ ecma_builtin_json_quote (ecma_stringbuilder_t *builder_p, /**< builder for the r
#if ENABLED (JERRY_ESNEXT)
if (lit_is_code_point_utf16_high_surrogate (c))
{
const ecma_char_t next_ch = lit_cesu8_peek_next (str_p);
if (lit_is_code_point_utf16_low_surrogate (next_ch))
if (str_p < str_end_p)
{
str_p += LIT_UTF8_MAX_BYTES_IN_CODE_UNIT;
continue;
const ecma_char_t next_ch = lit_cesu8_peek_next (str_p);
if (lit_is_code_point_utf16_low_surrogate (next_ch))
{
str_p += LIT_UTF8_MAX_BYTES_IN_CODE_UNIT;
continue;
}
should_escape = true;
}
else
{