mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-27 00:20:44 +00:00
fix pointer null
Signed-off-by: dengxiaoyu <dengxiaoyu6@huawei.com>
This commit is contained in:
parent
9e52983fb3
commit
faba52a477
@ -75,6 +75,10 @@ bool IsValidPath(const std::string &inFilePath, std::string &realFilePath)
|
||||
}
|
||||
|
||||
realFilePath = std::string(path);
|
||||
if (realFilePath.empty()) {
|
||||
HILOGE("Real file path is empty.");
|
||||
return false;
|
||||
}
|
||||
if (!std::filesystem::exists(realFilePath)) {
|
||||
HILOGE("The real file path %{public}s does not exist in the file system.", realFilePath.c_str());
|
||||
realFilePath = "";
|
||||
@ -207,7 +211,10 @@ int32_t GetCurrentMissionId()
|
||||
return INVALID_MISSION_ID;
|
||||
}
|
||||
int32_t missionId = INVALID_MISSION_ID;
|
||||
AAFwk::AbilityManagerClient::GetInstance()->GetMissionIdByToken(token, missionId);
|
||||
if (AAFwk::AbilityManagerClient::GetInstance()->GetMissionIdByToken(token, missionId) != ERR_OK) {
|
||||
HILOGE("GetMissionIdByToken failed");
|
||||
return INVALID_MISSION_ID;
|
||||
}
|
||||
return missionId;
|
||||
}
|
||||
|
||||
@ -411,6 +418,10 @@ bool CJsonParamCheck(const cJSON *jsonObj, const std::initializer_list<std::stri
|
||||
HILOGE("Check is not supported yet, key %{public}s.", (*it).c_str());
|
||||
return false;
|
||||
}
|
||||
if (iter->second == nullptr) {
|
||||
HILOGE("JsonTypeCheckFunc for key %{public}s is nullptr.", (*it).c_str());
|
||||
return false;
|
||||
}
|
||||
JsonTypeCheckFunc &func = iter->second;
|
||||
bool res = (*func)(paramValue);
|
||||
if (!res) {
|
||||
|
@ -57,6 +57,10 @@ int32_t DistributedClient::RegisterDSchedEventListener(const DSchedEventType& ty
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
PARCEL_WRITE_HELPER(data, Uint8, type);
|
||||
if (obj == nullptr) {
|
||||
HILOG_ERROR("Received null IDSchedEventListener object");
|
||||
return AAFwk::INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
PARCEL_WRITE_HELPER(data, RemoteObject, obj->AsObject());
|
||||
PARCEL_TRANSACT_SYNC_RET_INT(remote, static_cast<uint32_t>(IDSchedInterfaceCode::REGISTER_DSCHED_EVENT_LISTENER),
|
||||
data, reply);
|
||||
@ -78,6 +82,10 @@ int32_t DistributedClient::UnRegisterDSchedEventListener(const DSchedEventType&
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
PARCEL_WRITE_HELPER(data, Uint8, type);
|
||||
if (obj == nullptr) {
|
||||
HILOG_ERROR("Received null IDSchedEventListener object");
|
||||
return AAFwk::INVALID_PARAMETERS_ERR;
|
||||
}
|
||||
PARCEL_WRITE_HELPER(data, RemoteObject, obj->AsObject());
|
||||
PARCEL_TRANSACT_SYNC_RET_INT(remote, static_cast<uint32_t>(IDSchedInterfaceCode::UNREGISTER_DSCHED_EVENT_LISTENER),
|
||||
data, reply);
|
||||
|
@ -57,6 +57,10 @@ int32_t DSchedEventListenerStub::OnRemoteRequest(uint32_t code,
|
||||
}
|
||||
|
||||
auto memberFunc = itFunc->second;
|
||||
if (!memberFunc) {
|
||||
HILOGE("memberFunc is null for code %u", code);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
(this->*memberFunc)(data, reply);
|
||||
return 0;
|
||||
}
|
||||
|
@ -26,7 +26,16 @@ DmsSaClient &DmsSaClient::GetInstance()
|
||||
bool DmsSaClient::SubscribeDmsSA()
|
||||
{
|
||||
HILOGD("called.");
|
||||
if (!saMgrProxy_) {
|
||||
HILOGE("saMgrProxy_ is null.");
|
||||
return false;
|
||||
}
|
||||
sptr<DmsSystemAbilityStatusChange> callback(new DmsSystemAbilityStatusChange());
|
||||
if (!callback) {
|
||||
HILOGE("Failed to create callback object.");
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ret = saMgrProxy_->SubscribeSystemAbility(DISTRIBUTED_SCHED_SA_ID, callback);
|
||||
if (ret != ERR_OK) {
|
||||
HILOGE("Failed to subscribe system ability DISTRIBUTED_SCHED_SA_ID ret:%{public}d", ret);
|
||||
|
@ -806,6 +806,10 @@ bool JsContinuationManager::UnWrapContinuationExtraParams(const napi_env &env, c
|
||||
HILOGE("options is invalid.");
|
||||
return false;
|
||||
}
|
||||
if (!continuationExtraParams) {
|
||||
HILOGE("continuationExtraParams is nullptr.");
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> deviceTypes;
|
||||
if (UnwrapStringArrayByPropertyName(env, options, "deviceType", deviceTypes)) {
|
||||
continuationExtraParams->SetDeviceType(deviceTypes);
|
||||
|
@ -96,6 +96,11 @@ void JsDeviceSelectionListener::CallJsMethodInner(const std::string& methodName,
|
||||
const std::vector<ContinuationResult>& continuationResults)
|
||||
{
|
||||
std::lock_guard<std::mutex> jsCallBackMapLock(jsCallBackMapMutex_);
|
||||
auto it = jsCallBackMap_.find(methodName);
|
||||
if (it == jsCallBackMap_.end()) {
|
||||
HILOGE("Callback method %s not found in jsCallBackMap_", methodName.c_str());
|
||||
return;
|
||||
}
|
||||
napi_value method = jsCallBackMap_[methodName]->GetNapiValue();
|
||||
if (method == nullptr) {
|
||||
HILOGE("Failed to get %{public}s from object", methodName.c_str());
|
||||
@ -135,6 +140,11 @@ void JsDeviceSelectionListener::CallJsMethodInner(const std::string& methodName,
|
||||
const std::vector<std::string>& deviceIds)
|
||||
{
|
||||
std::lock_guard<std::mutex> jsCallBackMapLock(jsCallBackMapMutex_);
|
||||
auto it = jsCallBackMap_.find(methodName);
|
||||
if (it == jsCallBackMap_.end()) {
|
||||
HILOGE("Callback method %s not found in jsCallBackMap_", methodName.c_str());
|
||||
return;
|
||||
}
|
||||
napi_value method = jsCallBackMap_[methodName]->GetNapiValue();
|
||||
if (method == nullptr) {
|
||||
HILOGE("Failed to get %{public}s from object", methodName.c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user