diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_installer_proxy.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_installer_proxy.cpp index dae182cf..219a50a0 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_installer_proxy.cpp +++ b/interfaces/inner_api/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");