Tagged template literal array should be marked after construction (#4420)

This patch fixes #4385.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik 2021-01-08 13:07:34 +01:00 committed by GitHub
parent d161e2d9ed
commit 238f9aab4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 2 deletions

View File

@ -110,6 +110,16 @@ parser_new_tagged_template_literal (ecma_object_t **raw_strings_p) /**< [out] ra
ecma_object_t *template_obj_p = ecma_op_new_array_object (0);
*raw_strings_p = ecma_op_new_array_object (0);
ecma_extended_object_t *template_ext_obj_p = (ecma_extended_object_t *) template_obj_p;
ecma_extended_object_t *raw_ext_obj_p = (ecma_extended_object_t *) *raw_strings_p;
const uint8_t flags = ECMA_PROPERTY_TYPE_VIRTUAL | ECMA_PROPERTY_FLAG_WRITABLE | ECMA_FAST_ARRAY_FLAG;
JERRY_ASSERT (template_ext_obj_p->u.array.length_prop_and_hole_count == flags);
JERRY_ASSERT (raw_ext_obj_p->u.array.length_prop_and_hole_count == flags);
template_ext_obj_p->u.array.length_prop_and_hole_count = flags | ECMA_ARRAY_TEMPLATE_LITERAL;
raw_ext_obj_p->u.array.length_prop_and_hole_count = flags | ECMA_ARRAY_TEMPLATE_LITERAL;
ecma_builtin_helper_def_prop (template_obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_RAW),
ecma_make_object_value (*raw_strings_p),
@ -125,11 +135,9 @@ static void
parser_tagged_template_literal_freeze_array (ecma_object_t *obj_p)
{
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_ARRAY);
ecma_op_ordinary_object_prevent_extensions (obj_p);
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
ext_obj_p->u.array.length_prop_and_hole_count &= (uint32_t) ~ECMA_PROPERTY_FLAG_WRITABLE;
ext_obj_p->u.array.length_prop_and_hole_count |= ECMA_ARRAY_TEMPLATE_LITERAL;
} /* parser_tagged_template_literal_freeze_array */
/**

View File

@ -0,0 +1,20 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
try {
eval('P`${*\x10$');
assert(false);
} catch (e) {
assert(e instanceof SyntaxError);
}