Fix String.prototype.repeat for empty strings (#3085)

This patch fixes #3084.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2019-09-10 15:03:53 +02:00
committed by Dániel Bátyai
parent c04fe24253
commit 83459c1fac
2 changed files with 18 additions and 3 deletions
@@ -1907,13 +1907,13 @@ ecma_builtin_string_prototype_object_repeat (ecma_string_t *original_string_p, /
return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid count value"));
}
if (length == 0 || isNan)
lit_utf8_size_t size = ecma_string_get_utf8_size (original_string_p);
if (length == 0 || size == 0 || isNan)
{
return ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
lit_utf8_size_t size = ecma_string_get_utf8_size (original_string_p);
if ((uint32_t) length >= (ECMA_STRING_SIZE_LIMIT / size))
{
return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid string length"));