!914 fix: nullptr

Merge pull request !914 from zhouoaoteng/master
This commit is contained in:
openharmony_ci 2024-08-17 08:31:30 +00:00 committed by Gitee
commit ce86b8c67c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

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");