!1428 fix:check promote return

Merge pull request !1428 from crazy_hu/master
This commit is contained in:
openharmony_ci 2024-10-16 12:39:26 +00:00 committed by Gitee
commit cd2b3259d3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 9 additions and 5 deletions

View File

@ -30,6 +30,10 @@ void DbinderDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
}
sptr<IRemoteObject> object = remote.promote();
if (object == nullptr) {
DBINDER_LOGE(LOG_LABEL, "Remote object is null");
return;
}
IPCObjectProxy *callbackProxy = reinterpret_cast<IPCObjectProxy *>(object.GetRefPtr());
sptr<DBinderService> dBinderService = DBinderService::GetInstance();

View File

@ -680,7 +680,7 @@ HWTEST_F(DBinderServiceUnitTest, OnRemoteInvokerMessage002, TestSize.Level1)
EXPECT_TRUE(dBinderService != nullptr);
std::shared_ptr<struct DHandleEntryTxRx> message = std::make_shared<DHandleEntryTxRx>();
EXPECT_TRUE(message != nullptr);
memset_s(message.get(), sizeof(DHandleEntryTxRx), 0, sizeof(DHandleEntryTxRx));
(void)memset_s(message.get(), sizeof(DHandleEntryTxRx), 0, sizeof(DHandleEntryTxRx));
message->stubIndex = TEST_STUB_INDEX;
dBinderService->dbinderCallback_ = std::make_shared<TestRpcSystemAbilityCallback>();
EXPECT_TRUE(dBinderService->dbinderCallback_ != nullptr);
@ -1024,7 +1024,7 @@ HWTEST_F(DBinderServiceUnitTest, MakeSessionByReplyMessageTest001, TestSize.Leve
EXPECT_TRUE(dBinderService != nullptr);
std::shared_ptr<struct DHandleEntryTxRx> replyMessage = std::make_shared<DHandleEntryTxRx>();
EXPECT_TRUE(replyMessage != nullptr);
memset_s(replyMessage.get(), sizeof(DHandleEntryTxRx), 0, sizeof(DHandleEntryTxRx));
(void)memset_s(replyMessage.get(), sizeof(DHandleEntryTxRx), 0, sizeof(DHandleEntryTxRx));
dBinderService->MakeSessionByReplyMessage(replyMessage);
EXPECT_EQ(dBinderService->HasDBinderStub(replyMessage->binderObject), false);
@ -1148,7 +1148,7 @@ HWTEST_F(DBinderServiceUnitTest, OnRemoteInvokerDataBusMessageTest001, TestSize.
uint32_t tokenId = 1;
std::shared_ptr<struct DHandleEntryTxRx> replyMessage = std::make_shared<DHandleEntryTxRx>();
EXPECT_TRUE(replyMessage != nullptr);
memset_s(replyMessage.get(), sizeof(DHandleEntryTxRx), 0, sizeof(DHandleEntryTxRx));
(void)memset_s(replyMessage.get(), sizeof(DHandleEntryTxRx), 0, sizeof(DHandleEntryTxRx));
EXPECT_EQ(dBinderService->OnRemoteInvokerDataBusMessage(
proxy, replyMessage, remoteDeviceId, pid, uid, tokenId), DBinderErrorCode::DEVICEID_INVALID);
}
@ -1169,7 +1169,7 @@ HWTEST_F(DBinderServiceUnitTest, OnRemoteInvokerDataBusMessageTest002, TestSize.
IPCObjectProxy objectProxy(0);
std::shared_ptr<struct DHandleEntryTxRx> replyMessage = std::make_shared<DHandleEntryTxRx>();
EXPECT_TRUE(replyMessage != nullptr);
memset_s(replyMessage.get(), sizeof(DHandleEntryTxRx), 0, sizeof(DHandleEntryTxRx));
(void)memset_s(replyMessage.get(), sizeof(DHandleEntryTxRx), 0, sizeof(DHandleEntryTxRx));
EXPECT_EQ(dBinderService->OnRemoteInvokerDataBusMessage(
&objectProxy, replyMessage, remoteDeviceId, pid, uid, tokenId), DBinderErrorCode::SESSION_NAME_NOT_FOUND);
}
@ -1306,7 +1306,7 @@ HWTEST_F(DBinderServiceUnitTest, PopLoadSaItemTest001, TestSize.Level1)
srcNetworkId = "t";
std::shared_ptr<struct DHandleEntryTxRx> message = std::make_shared<DHandleEntryTxRx>();
EXPECT_TRUE(message != nullptr);
memset_s(message.get(), sizeof(DHandleEntryTxRx), 0, sizeof(DHandleEntryTxRx));
(void)memset_s(message.get(), sizeof(DHandleEntryTxRx), 0, sizeof(DHandleEntryTxRx));
message->stubIndex = systemAbilityId;
message->deviceIdInfo.fromDeviceId[0] = 't';
dBinderService->dbinderCallback_ = std::make_shared<TestRpcSystemAbilityCallback>();