Skip to content

Commit

Permalink
Add stack limit check to proxy operations
Browse files Browse the repository at this point in the history
Fixes #3785.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai [email protected]
  • Loading branch information
dbatyai committed May 25, 2020
1 parent edaf4ef commit e2e4818
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions jerry-core/ecma/operations/ecma-proxy-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "ecma-objects.h"
#include "ecma-objects-general.h"
#include "ecma-proxy-object.h"
#include "jcontext.h"

/** \addtogroup ecma ECMA
* @{
Expand Down Expand Up @@ -994,6 +995,7 @@ ecma_proxy_object_has (ecma_object_t *obj_p, /**< proxy object */
ecma_string_t *prop_name_p) /**< property name */
{
JERRY_ASSERT (ECMA_OBJECT_IS_PROXY (obj_p));
ECMA_CHECK_STACK_USAGE ();

ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) obj_p;

Expand Down Expand Up @@ -1097,6 +1099,7 @@ ecma_proxy_object_get (ecma_object_t *obj_p, /**< proxy object */
ecma_value_t receiver) /**< receiver to invoke getter function */
{
JERRY_ASSERT (ECMA_OBJECT_IS_PROXY (obj_p));
ECMA_CHECK_STACK_USAGE ();

ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) obj_p;

Expand Down Expand Up @@ -1201,6 +1204,7 @@ ecma_proxy_object_set (ecma_object_t *obj_p, /**< proxy object */
ecma_value_t receiver) /**< receiver to invoke setter function */
{
JERRY_ASSERT (ECMA_OBJECT_IS_PROXY (obj_p));
ECMA_CHECK_STACK_USAGE ();

ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) obj_p;

Expand Down
37 changes: 37 additions & 0 deletions tests/jerry/es2015/regression-test-issue-3785.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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.

var a = new Proxy({length:2}, {});
a.__proto__ = a;

try {
a[1];
assert (false);
} catch (e) {
assert (e instanceof RangeError);
}

try {
a[1] = 2;
assert (false);
} catch (e) {
assert (e instanceof RangeError);
}

try {
Array.prototype.forEach.call(a, ()=>{});
assert (false);
} catch (e) {
assert (e instanceof RangeError);
}

0 comments on commit e2e4818

Please sign in to comment.