From be1bfb5a05c77405e89371bd4f2546530c491049 Mon Sep 17 00:00:00 2001 From: zengzengran Date: Wed, 9 Jul 2025 16:40:28 +0800 Subject: [PATCH] Fixing invalid call function crash Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICL4N2 Description: Problem Description: Circular dependency element, tstype without expr set to TypeError, subsequent use of nullptr's tstype causes segv Tested-by: ninja tests (passed) ets_testrunner (passed) Signed-off-by: zengzengran # --- ets2panda/checker/ETSAnalyzer.cpp | 1 + .../compiler/ets/fuzz_invalid_property.ets | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 ets2panda/test/ast/compiler/ets/fuzz_invalid_property.ets diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 93c5975a50..37e084f542 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -1444,6 +1444,7 @@ checker::Type *ETSAnalyzer::Check(ir::CallExpression *expr) const checker::TypeStackElement tse(checker, expr, {{diagnostic::CYCLIC_CALLEE, {}}}, expr->Start()); if (tse.HasTypeError()) { + expr->SetTsType(checker->GlobalTypeError()); return checker->GlobalTypeError(); } diff --git a/ets2panda/test/ast/compiler/ets/fuzz_invalid_property.ets b/ets2panda/test/ast/compiler/ets/fuzz_invalid_property.ets new file mode 100644 index 0000000000..93b7801f20 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/fuzz_invalid_property.ets @@ -0,0 +1,21 @@ +/* + * 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. + */ + +class D{ + strB = (new StringBuilder).append('{ ').append(strB.toString()).append(' }') +} + +/* @@? 17:12 Error TypeError: Circular call function */ +/* @@? 17:52 Error TypeError: Property 'strB' must be accessed through 'this' */ -- Gitee