From cbcb6adeb54e8d92bab410e52985ed64dfd8bd88 Mon Sep 17 00:00:00 2001 From: dy_study Date: Wed, 14 Sep 2022 15:55:31 +0800 Subject: [PATCH] =?UTF-8?q?IssueNo:#I5R1HG=20Description:=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=B8=8D=E8=A7=A3=E5=8E=8B=E5=B7=A5=E5=85=B7=E7=B1=BB?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E7=A9=BA=E6=8C=87=E9=92=88=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20Sig:SIG=5FApplicationFramework=20Feature=20or=20Bug?= =?UTF-8?q?fix:Bugfix=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dy_study Change-Id: I609ba4ffbaa9106b7dd70c43952324052ce2df37 --- frameworks/native/runtime/js_runtime.cpp | 9 +++++++++ .../native/runtime/utils/src/runtime_extractor.cpp | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index 8b3c82831f..e717b5946f 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -121,6 +121,9 @@ public: std::shared_ptr runtimeExtractor; if (runtimeExtractorMap_.find(hapPath) == runtimeExtractorMap_.end()) { runtimeExtractor = RuntimeExtractor::Create(hapPath); + if (runtimeExtractor == nullptr) { + return result; + } runtimeExtractor->SetRuntimeFlag(true); runtimeExtractorMap_.insert(make_pair(hapPath, runtimeExtractor)); } else { @@ -261,6 +264,9 @@ private: bundleName_ = options.bundleName; panda::JSNApi::SetHostResolvePathTracker(vm_, JsModuleSearcher(options.bundleName)); std::shared_ptr runtimeExtractor = RuntimeExtractor::Create(options.hapPath); + if (runtimeExtractor == nullptr) { + return false; + } runtimeExtractor->SetRuntimeFlag(true); runtimeExtractorMap_.insert(make_pair(options.hapPath, runtimeExtractor)); panda::JSNApi::SetHostResolveBufferTracker( @@ -615,6 +621,9 @@ bool JsRuntime::RunScript(const std::string& srcPath, const std::string& hapPath std::shared_ptr runtimeExtractor; if (runtimeExtractorMap_.find(hapPath) == runtimeExtractorMap_.end()) { runtimeExtractor = RuntimeExtractor::Create(hapPath); + if (runtimeExtractor == nullptr) { + return result; + } runtimeExtractor->SetRuntimeFlag(true); runtimeExtractorMap_.insert(make_pair(hapPath, runtimeExtractor)); } else { diff --git a/frameworks/native/runtime/utils/src/runtime_extractor.cpp b/frameworks/native/runtime/utils/src/runtime_extractor.cpp index 828a2499a3..833fd911b5 100644 --- a/frameworks/native/runtime/utils/src/runtime_extractor.cpp +++ b/frameworks/native/runtime/utils/src/runtime_extractor.cpp @@ -49,7 +49,7 @@ std::shared_ptr RuntimeExtractor::Create(const std::string& ha { if (hapPath.empty()) { HILOG_ERROR("source is nullptr"); - return std::shared_ptr(); + return nullptr; } std::string loadPath; @@ -61,7 +61,7 @@ std::shared_ptr RuntimeExtractor::Create(const std::string& ha std::shared_ptr runtimeExtractor = std::make_shared(loadPath); if (!runtimeExtractor->Init()) { HILOG_ERROR("RuntimeExtractor create failed"); - return std::shared_ptr(); + return nullptr; } return runtimeExtractor;