Skip to content

Commit 012b81c

Browse files
committed
Add stack limit check to proxy operations
Fixes jerryscript-project#3785. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai [email protected]
1 parent 589af6d commit 012b81c

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

Diff for: jerry-core/ecma/operations/ecma-proxy-object.c

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "ecma-objects.h"
2626
#include "ecma-objects-general.h"
2727
#include "ecma-proxy-object.h"
28+
#include "jcontext.h"
2829

2930
/** \addtogroup ecma ECMA
3031
* @{
@@ -993,6 +994,7 @@ ecma_value_t
993994
ecma_proxy_object_has (ecma_object_t *obj_p, /**< proxy object */
994995
ecma_string_t *prop_name_p) /**< property name */
995996
{
997+
ECMA_CHECK_STACK_USAGE ();
996998
JERRY_ASSERT (ECMA_OBJECT_IS_PROXY (obj_p));
997999

9981000
ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) obj_p;
@@ -1096,6 +1098,7 @@ ecma_proxy_object_get (ecma_object_t *obj_p, /**< proxy object */
10961098
ecma_string_t *prop_name_p, /**< property name */
10971099
ecma_value_t receiver) /**< receiver to invoke getter function */
10981100
{
1101+
ECMA_CHECK_STACK_USAGE ();
10991102
JERRY_ASSERT (ECMA_OBJECT_IS_PROXY (obj_p));
11001103

11011104
ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) obj_p;
@@ -1200,6 +1203,7 @@ ecma_proxy_object_set (ecma_object_t *obj_p, /**< proxy object */
12001203
ecma_value_t value, /**< value to set */
12011204
ecma_value_t receiver) /**< receiver to invoke setter function */
12021205
{
1206+
ECMA_CHECK_STACK_USAGE ();
12031207
JERRY_ASSERT (ECMA_OBJECT_IS_PROXY (obj_p));
12041208

12051209
ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) obj_p;

Diff for: tests/jerry/es2015/regression-test-issue-3785.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 a = new Proxy({length:2}, {});
16+
a.__proto__ = a;
17+
18+
try {
19+
a[1];
20+
assert (false);
21+
} catch (e) {
22+
assert (e instanceof RangeError);
23+
}
24+
25+
try {
26+
a[1] = 2;
27+
assert (false);
28+
} catch (e) {
29+
assert (e instanceof RangeError);
30+
}
31+
32+
try {
33+
Array.prototype.forEach.call(a, ()=>{});
34+
assert (false);
35+
} catch (e) {
36+
assert (e instanceof RangeError);
37+
}

0 commit comments

Comments
 (0)