Throw JSERROR when load invalid input hsp path

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IA4N1O?from=project-issue

Signed-off-by: chenjx-huawei <chenjingxiang1@huawei.com>
Change-Id: I1c93dbaed6393e7f821885c1eabab31e094c2038
This commit is contained in:
chenjx-huawei 2024-06-12 12:08:09 +08:00
parent 669297c4ca
commit e8ca8bb697
2 changed files with 5 additions and 0 deletions

View File

@ -83,6 +83,10 @@ std::shared_ptr<JSPandaFile> JSPandaFileManager::LoadJSPandaFile(JSThread *threa
std::string hspPath = ModulePathHelper::ParseHapPath(filename);
if (hspPath.empty()) {
LOG_FULL(ERROR) << ModuleMessageHelper::VmModuleInfoMessage(thread);
if (!thread->IsMainThread()) {
CString msg = "Invalid input hsp path: " + filename;
THROW_TYPE_ERROR_AND_RETURN(thread, msg.c_str(), nullptr);
}
LOG_FULL(FATAL) << "Invalid input hsp path: " << filename;
return nullptr;
}

View File

@ -133,6 +133,7 @@ JSHandle<JSTaggedValue> SharedModuleManager::ResolveImportedModuleWithMerge(JSTh
{
std::shared_ptr<JSPandaFile> jsPandaFile = ModulePathHelper::SkipDefaultBundleFile(thread, fileName) ? nullptr :
JSPandaFileManager::GetInstance()->LoadJSPandaFile(thread, fileName, recordName, false);
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
if (jsPandaFile == nullptr) {
// In Aot Module Instantiate, we miss some runtime parameters from framework like bundleName or moduleName
// which may cause wrong recordName parsing and we also can't load files not in this app hap. But in static