Skip to content

Commit 58e504f

Browse files
authored
Add stack-overflow check for general [[Construct]] method of function objects (#4945)
This patch fixes #4901 JerryScript-DCO-1.0-Signed-off-by: Martin Negyokru [email protected]
1 parent f3a420b commit 58e504f

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

.github/workflows/gh-actions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ jobs:
148148
- run: >-
149149
$RUNNER -q --jerry-tests
150150
--buildoptions=--stack-limit=0,--compile-flag=-fsanitize=address,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--compile-flag=-O2,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold
151-
--skip-list=parser-oom.js,parser-oom2.js,stack-limit.js,regression-test-issue-4848.js,regression-test-issue-4890.js,regression-test-issue-2190.js,regression-test-issue-2258-2963.js,regression-test-issue-2448.js,regression-test-issue-2905.js,regression-test-issue-3785.js,proxy-evil-recursion.js
151+
--skip-list=parser-oom.js,parser-oom2.js,stack-limit.js,regression-test-issue-4901.js,regression-test-issue-4848.js,regression-test-issue-4890.js,regression-test-issue-2190.js,regression-test-issue-2258-2963.js,regression-test-issue-2448.js,regression-test-issue-2905.js,regression-test-issue-3785.js,proxy-evil-recursion.js
152152
153153
ASAN_Tests_Debug:
154154
runs-on: ubuntu-latest
@@ -161,7 +161,7 @@ jobs:
161161
- run: >-
162162
$RUNNER -q --jerry-tests --build-debug
163163
--buildoptions=--stack-limit=0,--compile-flag=-fsanitize=address,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--compile-flag=-O2,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold
164-
--skip-list=parser-oom.js,parser-oom2.js,stack-limit.js,regression-test-issue-4848.js,regression-test-issue-4890.js,regression-test-issue-2190.js,regression-test-issue-2258-2963.js,regression-test-issue-2448.js,regression-test-issue-2905.js,regression-test-issue-3785.js,proxy-evil-recursion.js
164+
--skip-list=parser-oom.js,parser-oom2.js,stack-limit.js,regression-test-issue-4901.js,regression-test-issue-4848.js,regression-test-issue-4890.js,regression-test-issue-2190.js,regression-test-issue-2258-2963.js,regression-test-issue-2448.js,regression-test-issue-2905.js,regression-test-issue-3785.js,proxy-evil-recursion.js
165165
166166
UBSAN_Tests:
167167
runs-on: ubuntu-latest

jerry-core/ecma/operations/ecma-function-object.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,8 @@ ecma_op_function_construct (ecma_object_t *func_obj_p, /**< Function object */
17691769
{
17701770
JERRY_ASSERT (func_obj_p != NULL && !ecma_is_lexical_environment (func_obj_p));
17711771

1772+
ECMA_CHECK_STACK_USAGE ();
1773+
17721774
switch (ecma_get_object_type (func_obj_p))
17731775
{
17741776
case ECMA_OBJECT_TYPE_FUNCTION:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
function foo() {
16+
new foo();
17+
}
18+
19+
try {
20+
foo();
21+
assert(false)
22+
} catch (e) {
23+
assert(e instanceof RangeError);
24+
}

0 commit comments

Comments
 (0)