From 1f83e4067a79f0e3803af82e11fc1a22b1eb5233 Mon Sep 17 00:00:00 2001 From: ElevenDuan Date: Fri, 11 Jul 2025 09:15:17 +0800 Subject: [PATCH] Fix the issue of accessing invalid memory Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICLL1D?from=project-issue Signed-off-by: ElevenDuan Change-Id: I86154f12b6acc5396780bfa4a7d7e1c1b6bc20a0 --- es2panda/compiler/core/compileQueue.cpp | 8 +++++++- merge_abc/src/protobufSnapshotGenerator.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/es2panda/compiler/core/compileQueue.cpp b/es2panda/compiler/core/compileQueue.cpp index 6a6ddeab5a..46739bbe06 100644 --- a/es2panda/compiler/core/compileQueue.cpp +++ b/es2panda/compiler/core/compileQueue.cpp @@ -106,8 +106,12 @@ bool CompileFileJob::RetrieveProgramFromCacheFiles(const std::string &buffer, bo cacheFileIter->second, &allocator); if (cacheAbcProgramsInfo != nullptr && cacheAbcProgramsInfo->hashCode == src_->hash) { InsertAbcCachePrograms(src_->hash, cacheAbcProgramsInfo->programsCache); + delete cacheAbcProgramsInfo; + cacheAbcProgramsInfo = nullptr; return true; } + delete cacheAbcProgramsInfo; + cacheAbcProgramsInfo = nullptr; } } return false; @@ -185,9 +189,11 @@ void CompileFileJob::CompileAbcFileJobInParallel(es2panda::Compiler &compiler) panda::Timer::timerStart(panda::EVENT_UPDATE_ABC_PROG_CACHE, src_->fileName); auto outputCacheIter = options_->cacheFiles.find(src_->fileName); if (!options_->requireGlobalOptimization && outputCacheIter != options_->cacheFiles.end()) { - auto *cache = allocator_->New(src_->hash, abcProgramsInfo); + auto *cache = new panda::es2panda::util::AbcProgramsCache(src_->hash, abcProgramsInfo); CHECK_NOT_NULL(cache); panda::proto::ProtobufSnapshotGenerator::UpdateAbcCacheFile(cache, outputCacheIter->second); + delete cache; + cache = nullptr; } InsertAbcCachePrograms(src_->hash, abcProgramsInfo); panda::Timer::timerEnd(panda::EVENT_UPDATE_ABC_PROG_CACHE, src_->fileName); diff --git a/merge_abc/src/protobufSnapshotGenerator.cpp b/merge_abc/src/protobufSnapshotGenerator.cpp index 11507c8fa5..5722f3c26e 100644 --- a/merge_abc/src/protobufSnapshotGenerator.cpp +++ b/merge_abc/src/protobufSnapshotGenerator.cpp @@ -107,7 +107,7 @@ panda::es2panda::util::AbcProgramsCache *ProtobufSnapshotGenerator::GetAbcInputC } uint32_t hashCode = abcProtoCache.hashcode(); - auto *abcProgarmsCache = allocator->New(hashCode, abcProgsInfo); + auto *abcProgarmsCache = new panda::es2panda::util::AbcProgramsCache(hashCode, abcProgsInfo); CHECK_NOT_NULL(abcProgarmsCache); return abcProgarmsCache; -- Gitee