Skip to content

Commit 7ea1937

Browse files
Fix the access error caused when a class is implemented to be empty
JerryScript-DCO-1.0-Signed-off-by: tangbin [email protected]
1 parent 5020015 commit 7ea1937

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

jerry-core/parser/js/js-parser-expr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ parser_parse_class (parser_context_t *context_p, /**< context */
10881088
}
10891089
}
10901090

1091-
if (class_name_index != PARSER_INVALID_LITERAL_INDEX)
1091+
if (class_name_index != PARSER_INVALID_LITERAL_INDEX && context_p->scope_stack_p != NULL)
10921092
{
10931093
if (JERRY_UNLIKELY (context_p->scope_stack_top >= context_p->scope_stack_size))
10941094
{

tests/jerry/class-empty-context.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
class v0 {v1 = class v2 { }}

0 commit comments

Comments
 (0)