Add a validation before evaluating the source code (#2480)
This patch checks whether the source code is a valid UTF-8 string before evaluating it in prompt mode. Also fixes #2476. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
@@ -810,6 +810,12 @@ main (int argc,
|
|||||||
|
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
|
if (!jerry_is_valid_utf8_string (buffer, (jerry_size_t) len))
|
||||||
|
{
|
||||||
|
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: Input must be a valid UTF-8 string.\n");
|
||||||
|
return JERRY_STANDALONE_EXIT_CODE_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Evaluate the line */
|
/* Evaluate the line */
|
||||||
jerry_value_t ret_val_eval = jerry_eval (buffer, len, JERRY_PARSE_NO_OPTS);
|
jerry_value_t ret_val_eval = jerry_eval (buffer, len, JERRY_PARSE_NO_OPTS);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user