From 3c90b56153ae226628679bcc0617274be59ffd59 Mon Sep 17 00:00:00 2001 From: F001 Date: Fri, 25 Jul 2025 11:14:34 +0800 Subject: [PATCH] fix array out of bounds in lexer Ensure the index is in the bounds of StringView. Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICOK8H Signed-off-by: F001 --- ets2panda/test/ast/parser/ets/lexer003.ets | 24 ++++++++++++++++++++++ ets2panda/util/ustring.h | 1 - 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 ets2panda/test/ast/parser/ets/lexer003.ets diff --git a/ets2panda/test/ast/parser/ets/lexer003.ets b/ets2panda/test/ast/parser/ets/lexer003.ets new file mode 100644 index 0000000000..6e9900937b --- /dev/null +++ b/ets2panda/test/ast/parser/ets/lexer003.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * 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. + */ + +/* @@? 24:1 Error SyntaxError: Unexpected token, expected '`'. */ +/* @@? 24:4 Error TypeError: Unresolved reference message */ +/* @@? 24:15 Error SyntaxError: Unterminated string. */ +/* @@? 24:19 Error SyntaxError: Unterminated string. */ +/* @@? 24:19 Error SyntaxError: Unexpected token, expected '${' or '`' */ +/* @@? 24:19 Error SyntaxError: Unexpected token, expected '`'. */ +/* @@? 24:19 Error SyntaxError: Expected '}', got 'end of stream'. */ + +`${message ?? 'ver \ No newline at end of file diff --git a/ets2panda/util/ustring.h b/ets2panda/util/ustring.h index b9106cc62b..c6becf1661 100644 --- a/ets2panda/util/ustring.h +++ b/ets2panda/util/ustring.h @@ -202,7 +202,6 @@ public: inline void Reset(size_t offset) { - ES2PANDA_ASSERT(sv_.begin() + offset <= sv_.end()); iter_ = sv_.begin() + offset; } -- Gitee