!162 增加new nothrow空指针判断

Merge pull request !162 from 王旭/master
This commit is contained in:
openharmony_ci 2022-05-08 01:53:39 +00:00 committed by Gitee
commit 8e92c28456
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 13 additions and 5 deletions

View File

@ -68,7 +68,11 @@ uint64_t AuthResManager::Register(std::shared_ptr<ResAuthExecutor> executorInfo,
// Assign messenger
sptr<UserIAM::AuthResPool::IExecutorMessenger> messenger =
new UserIAM::AuthResPool::ExecutorMessenger(&coAuthResPool_);
new (std::nothrow) UserIAM::AuthResPool::ExecutorMessenger(&coAuthResPool_);
if (messenger == nullptr) {
COAUTH_HILOGE(MODULE_SERVICE, "messenger is nullptr");
return INVALID_EXECUTOR_ID;
}
callback->OnMessengerReady(messenger);
COAUTH_HILOGD(MODULE_SERVICE, "register is successfull, exeID is 0xXXXX%{public}04" PRIx64, MASK & executorId);
return executorId;

View File

@ -204,8 +204,10 @@ int32_t UserIDMController::UpdateCredentialCtrl(int32_t userId, uint64_t callerI
data_->InsertScheduleId(scheduleId);
std::shared_ptr<UserIDMCoAuthHandler> coAuthCallback =
std::make_shared<UserIDMCoAuthHandler>(MODIFY_CRED, challenge, scheduleId, data_, innerkitsCallback);
sptr<IRemoteObject::DeathRecipient> dr = new CoAuthCallbackDeathRecipient(coAuthCallback);
if (!innerkitsCallback->AsObject()->AddDeathRecipient(dr)) {
sptr<IRemoteObject::DeathRecipient> dr = new (std::nothrow) CoAuthCallbackDeathRecipient(coAuthCallback);
if (dr == nullptr) {
COAUTH_HILOGE(MODULE_SERVICE, "dr is nullptr");
} else if (!innerkitsCallback->AsObject()->AddDeathRecipient(dr)) {
USERIDM_HILOGE(MODULE_SERVICE, "Failed to add death recipient CoAuthCallbackDeathRecipient");
}
CoAuth::AuthInfo paramInfo;
@ -254,8 +256,10 @@ int32_t UserIDMController::DelFaceCredentialCtrl(AuthType authType, AuthSubType
}
std::shared_ptr<UserIDMSetPropHandler> setPropCallback =
std::make_shared<UserIDMSetPropHandler>(FACE, 0, 0, credentialId, data_, innerCallback);
sptr<IRemoteObject::DeathRecipient> dr = new SetPropCallbackDeathRecipient(setPropCallback);
if (!innerCallback->AsObject()->AddDeathRecipient(dr)) {
sptr<IRemoteObject::DeathRecipient> dr = new (std::nothrow) SetPropCallbackDeathRecipient(setPropCallback);
if (dr == nullptr) {
COAUTH_HILOGE(MODULE_SERVICE, "dr is nullptr");
} else if (!innerCallback->AsObject()->AddDeathRecipient(dr)) {
USERIDM_HILOGE(MODULE_SERVICE, "Failed to add death recipient SetPropCallbackDeathRecipient");
}
AuthResPool::AuthAttributes condition;