From 44c65cc878e3ce1f066fa106a073b92337e45f2c Mon Sep 17 00:00:00 2001 From: s00494828 Date: Fri, 13 May 2022 11:06:00 +0800 Subject: [PATCH] fix problem of nullptr Signed-off-by: s00494828 Change-Id: If59476c3c49314df0dd1cb676e55dfe1d96779cf --- .../appexecfwk_core/src/bundlemgr/bundle_installer_proxy.cpp | 3 +-- services/bundlemgr/src/bundle_installer_host.cpp | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_installer_proxy.cpp b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_installer_proxy.cpp index 947b1cf7..a57d6ebd 100644 --- a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_installer_proxy.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_installer_proxy.cpp @@ -365,13 +365,12 @@ ErrCode BundleInstallerProxy::WriteFileToStream(sptr &st int32_t outputFd = streamInstaller->CreateStream(hapName, 0); if (outputFd < 0) { APP_LOGE("write file to stream failed due to invalid file descriptor"); - close(outputFd); return ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID; } int32_t inputFd = open(path.c_str(), O_RDONLY); if (inputFd < 0) { - close(inputFd); + close(outputFd); APP_LOGE("write file to stream failed due to open the hap file"); return ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID; } diff --git a/services/bundlemgr/src/bundle_installer_host.cpp b/services/bundlemgr/src/bundle_installer_host.cpp index c40666ac..aa6d3c42 100644 --- a/services/bundlemgr/src/bundle_installer_host.cpp +++ b/services/bundlemgr/src/bundle_installer_host.cpp @@ -443,6 +443,10 @@ sptr BundleInstallerHost::CreateStreamInstaller(const In auto uid = IPCSkeleton::GetCallingUid(); sptr streamInstaller(new (std::nothrow) BundleStreamInstallerHostImpl( ++streamInstallerIds_, uid)); + if (streamInstaller == nullptr) { + APP_LOGE("streamInstaller is nullptr"); + return nullptr; + } bool res = streamInstaller->Init(installParam); if (!res) { APP_LOGE("stream installer init failed");