fix:nullptr

Signed-off-by: zhouoaoteng <zhouaoteng@huawei.com>
This commit is contained in:
zhouoaoteng 2024-08-16 18:53:22 +08:00
parent 51a8ff646e
commit d2833ee32d

View File

@ -201,9 +201,14 @@ sptr<IFileAccessExtBase> FileAccessService::ConnectExtension(Uri &uri, const sha
void FileAccessService::ResetProxy(const wptr<IRemoteObject> &remote)
{
HILOG_DEBUG("FileAccessService::ResetProxy start");
lock_guard<mutex> lock(mapMutex_);
if (remote != nullptr && extensionDeathRecipient_ != nullptr) {
for (auto iter = cMap_.begin(); iter != cMap_.end(); ++iter) {
if (iter->second == nullptr) {
HILOG_ERROR("iter->second is null or extensionDeathRecipient_ is null.");
continue;
}
auto proxyRemote = iter->second->AsObject();
if (proxyRemote != nullptr && proxyRemote == remote.promote()) {
proxyRemote->RemoveDeathRecipient(extensionDeathRecipient_);
@ -396,6 +401,7 @@ void FileAccessService::RemoveRelations(string &uriStr, shared_ptr<ObserverNode>
int FileAccessService::FindUri(const string &uriStr, shared_ptr<ObserverNode> &outObsNode)
{
lock_guard<mutex> lock(nodeMutex_);
HILOG_DEBUG("FindUri start");
auto iter = relationshipMap_.find(uriStr);
if (iter == relationshipMap_.end()) {
HILOG_ERROR("Can not find uri");
@ -581,6 +587,7 @@ int32_t FileAccessService::OnChange(Uri uri, NotifyType notifyType)
return ERR_URI;
}
string uris = uriStr.substr(uriIndex);
HILOG_DEBUG("OnChange FindUri start");
//When the path is not found, search for its parent path
if (FindUri(uriStr, node) != ERR_OK) {
size_t slashIndex = uriStr.rfind("/");
@ -600,6 +607,7 @@ int32_t FileAccessService::OnChange(Uri uri, NotifyType notifyType)
SendListNotify(uris, notifyType, node->obsCodeList_);
return ERR_OK;
}
HILOG_DEBUG("OnChange FindUri end");
SendListNotify(uris, notifyType, node->obsCodeList_);
if ((node->parent_ == nullptr) || (!node->parent_->needChildNote_)) {
HILOG_DEBUG("Do not need notify parent");