!8018 独立恢复指针判空安全修改

Merge pull request !8018 from jjxxx123/master
This commit is contained in:
openharmony_ci 2024-08-12 09:56:41 +00:00 committed by Gitee
commit 5fb9107e70
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 12 additions and 7 deletions

View File

@ -106,15 +106,15 @@ WSError SceneSessionManagerProxy::RecoverAndConnectSpecificSession(const sptr<IS
WLOGFE("Write InterfaceToken failed!");
return WSError::WS_ERROR_IPC_FAILED;
}
if (!data.WriteRemoteObject(sessionStage->AsObject())) {
if (!sessionStage || !data.WriteRemoteObject(sessionStage->AsObject())) {
WLOGFE("Write ISessionStage failed!");
return WSError::WS_ERROR_IPC_FAILED;
}
if (!data.WriteRemoteObject(eventChannel->AsObject())) {
if (!eventChannel || !data.WriteRemoteObject(eventChannel->AsObject())) {
WLOGFE("Write IWindowEventChannel failed!");
return WSError::WS_ERROR_IPC_FAILED;
}
if (!surfaceNode->Marshalling(data)) {
if (!surfaceNode || !surfaceNode->Marshalling(data)) {
WLOGFE("Write surfaceNode failed");
return WSError::WS_ERROR_IPC_FAILED;
}
@ -165,15 +165,15 @@ WSError SceneSessionManagerProxy::RecoverAndReconnectSceneSession(const sptr<ISe
WLOGFE("Write InterfaceToken failed!");
return WSError::WS_ERROR_IPC_FAILED;
}
if (!data.WriteRemoteObject(sessionStage->AsObject())) {
if (!sessionStage || !data.WriteRemoteObject(sessionStage->AsObject())) {
WLOGFE("Write ISessionStage failed!");
return WSError::WS_ERROR_IPC_FAILED;
}
if (!data.WriteRemoteObject(eventChannel->AsObject())) {
if (!eventChannel || !data.WriteRemoteObject(eventChannel->AsObject())) {
WLOGFE("Write IWindowEventChannel failed!");
return WSError::WS_ERROR_IPC_FAILED;
}
if (!surfaceNode->Marshalling(data)) {
if (!surfaceNode || !surfaceNode->Marshalling(data)) {
WLOGFE("Write surfaceNode failed");
return WSError::WS_ERROR_IPC_FAILED;
}

View File

@ -311,13 +311,15 @@ WMError WindowSceneSessionImpl::RecoverAndConnectSpecificSession()
sptr<ISessionStage> iSessionStage(this);
sptr<WindowEventChannel> channel = new (std::nothrow) WindowEventChannel(iSessionStage);
if (channel == nullptr) {
return WMError::WM_ERROR_NULLPTR;
}
sptr<IWindowEventChannel> eventChannel(channel);
sptr<Rosen::ISession> session;
sptr<IRemoteObject> token = context_ ? context_->GetToken() : nullptr;
if (token) {
property_->SetTokenState(true);
}
const WindowType type = GetType();
if (WindowHelper::IsSubWindow(type) && (property_->GetExtensionFlag() == false)) { // sub window
TLOGD(WmsLogTag::WMS_RECOVER, "SubWindow");
@ -372,6 +374,9 @@ WMError WindowSceneSessionImpl::RecoverAndReconnectSceneSession()
GetPersistentId(), state_);
sptr<ISessionStage> iSessionStage(this);
auto windowEventChannel = new (std::nothrow) WindowEventChannel(iSessionStage);
if (windowEventChannel == nullptr) {
return WMError::WM_ERROR_NULLPTR;
}
sptr<IWindowEventChannel> iWindowEventChannel(windowEventChannel);
sptr<IRemoteObject> token = context_ ? context_->GetToken() : nullptr;
sptr<Rosen::ISession> session;