Skip to content

Commit 1ff322b

Browse files
rerobikaLaszloLango
authored andcommitted
Ensure that symbol properties are not listed in ecma_builtin_list_lazy_property_names (#2734)
This patch fixes #2733. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
1 parent 924f4bb commit 1ff322b

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

jerry-core/ecma/builtin-objects/ecma-builtins.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,15 @@ ecma_builtin_list_lazy_property_names (ecma_object_t *object_p, /**< a built-in
943943
index = 0;
944944
}
945945

946+
#ifndef CONFIG_DISABLE_ES2015_SYMBOL_BUILTIN
947+
/* Builtin symbol properties are internal magic strings which must not be listed */
948+
if (curr_property_p->magic_string_id > LIT_NON_INTERNAL_MAGIC_STRING__COUNT)
949+
{
950+
curr_property_p++;
951+
continue;
952+
}
953+
#endif /* !CONFIG_DISABLE_ES2015_SYMBOL_BUILTIN */
954+
946955
ecma_string_t *name_p = ecma_get_magic_string ((lit_magic_string_id_t) curr_property_p->magic_string_id);
947956

948957
uint32_t bit_for_index = (uint32_t) 1u << index;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
var recursion_counter = 0;
16+
var recursion_limit = 1000;
17+
var fz_globalObject = this
18+
19+
function fz_is_primitive(value) {
20+
var value_type = typeof value
21+
if (value_type !== "function" && value_type !== "object")
22+
return value_type
23+
}
24+
25+
function fz_starts_with(str, pattern) {
26+
for (var i = 0; i < pattern.length; i++)
27+
if (str[i] !== pattern[i])
28+
return
29+
return true
30+
}
31+
32+
function fz_collect_values(value) {
33+
if (++recursion_counter >= recursion_limit) {
34+
return
35+
}
36+
37+
var primitive = fz_is_primitive(value)
38+
if (primitive)
39+
return
40+
var prop_names = Object.getOwnPropertyNames(value)
41+
for (var i = 0; i < prop_names.length; i++) {
42+
var prop_name = prop_names[i]
43+
if (!fz_starts_with(prop_name, "fz_")) {
44+
fz_collect_values(value[prop_name])
45+
}
46+
}
47+
}
48+
49+
fz_collect_values(fz_globalObject)

0 commit comments

Comments
 (0)