Fix invalid assertion CESU8-UTF8 buffer copy (#4946)

The UTF8 buffer size can be smaller then the CESU8 string's size so the UTF8 output is may truncated. Therefore we cannot ensure that the CESU8 buffer is read until the end.
This patch fixes #4920.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
Robert Fancsik
2022-01-14 10:03:47 +01:00
committed by GitHub
parent 85bad33fbf
commit d681f201c2
2 changed files with 18 additions and 1 deletions
+1 -1
View File
@@ -865,7 +865,7 @@ lit_convert_cesu8_string_to_utf8_string (const lit_utf8_byte_t *cesu8_string_p,
cesu8_cursor_p += read_size;
}
JERRY_ASSERT (cesu8_cursor_p == cesu8_end_p);
JERRY_ASSERT (cesu8_cursor_p <= cesu8_end_p);
JERRY_ASSERT (utf8_cursor_p <= utf8_end_p);
return (lit_utf8_byte_t) (utf8_cursor_p - utf8_string_p);