!9666 cj_ability添加对ffidata的判空检查

Merge pull request !9666 from yuzhuohao/cj_ability_nullptr_check
This commit is contained in:
openharmony_ci 2024-08-02 09:57:17 +00:00 committed by Gitee
commit ecc398a761
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 16 additions and 0 deletions

View File

@ -78,6 +78,10 @@ int64_t FFIAbilityDelegatorRegistryGetAbilityDelegator()
return INVALID_CODE;
}
auto cjDelegator = FFI::FFIData::Create<CJAbilityDelegator>(delegator);
if (cjDelegator == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "cj delegator is null.");
return INVALID_CODE;
}
return cjDelegator->GetID();
}
@ -100,6 +104,10 @@ int32_t FFIAbilityDelegatorExecuteShellCommand(int64_t id, const char* cmd, int6
return INVALID_CODE;
}
auto cJShellCmdResult = FFI::FFIData::Create<CJShellCmdResult>(cjDelegator->ExecuteShellCommand(cmd, timeoutSec));
if (cJShellCmdResult == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "cj shell command result is null.");
return INVALID_CODE;
}
return cJShellCmdResult->GetID();
}

View File

@ -57,6 +57,10 @@ void CJAbilityConnectCallback::OnAbilityConnectDone(
ElementNameHandle elementNameHandle = const_cast<AppExecFwk::ElementName*>(&element);
// The cj side is responsible for the release.
auto cjRemoteObj = FFI::FFIData::Create<AppExecFwk::CJRemoteObject>(remoteObject);
if (cjRemoteObj == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "remote object is empty.");
return;
}
g_cjAbilityConnectCallbackFuncs->onConnect(callbackId_, elementNameHandle, cjRemoteObj->GetID(), resultCode);
}

View File

@ -36,6 +36,10 @@ int64_t FFIAbilityGetAbilityContext(AbilityHandle abilityHandle)
return ERR_INVALID_INSTANCE_CODE;
}
auto cjContext = FFI::FFIData::Create<CJAbilityContext>(context);
if (cjContext == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "GetAbilityContext failed, abilityContext is null");
return ERR_INVALID_INSTANCE_CODE;
}
return cjContext->GetID();
}