!1392 解决stream install空指针问题

Merge pull request !1392 from shilei91/master
This commit is contained in:
openharmony_ci
2022-05-16 02:37:23 +00:00
committed by Gitee
2 changed files with 5 additions and 2 deletions
@@ -365,13 +365,12 @@ ErrCode BundleInstallerProxy::WriteFileToStream(sptr<IBundleStreamInstaller> &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;
}
@@ -443,6 +443,10 @@ sptr<IBundleStreamInstaller> BundleInstallerHost::CreateStreamInstaller(const In
auto uid = IPCSkeleton::GetCallingUid();
sptr<BundleStreamInstallerHostImpl> 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");