!38098 DetachFromMainTree中Crash问题修复

Merge pull request !38098 from 向首兴/DetachFromMainTreeUaf
This commit is contained in:
openharmony_ci 2024-07-20 13:29:52 +00:00 committed by Gitee
commit 3763d03dd4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 7 additions and 0 deletions

View File

@ -203,6 +203,10 @@ std::list<RefPtr<UINode>>::iterator UINode::RemoveChild(const RefPtr<UINode>& ch
AddDisappearingChild(child, std::distance(children_.begin(), iter));
}
MarkNeedSyncRenderTree(true);
if (isTraversing_) {
LOGF("Try to remove the child([%{public}s][%{public}d]) of node [%{public}s][%{public}d] when its children "
"is traversing", (*iter)->GetTag().c_str(), (*iter)->GetId(), GetTag().c_str(), GetId());
}
auto result = children_.erase(iter);
return result;
}
@ -554,9 +558,11 @@ void UINode::DetachFromMainTree(bool recursive)
OnDetachFromMainTree(recursive);
// if recursive = false, recursively call DetachFromMainTree(false), until we reach the first FrameNode.
bool isRecursive = recursive || AceType::InstanceOf<FrameNode>(this);
isTraversing_ = true;
for (const auto& child : GetChildren()) {
child->DetachFromMainTree(isRecursive);
}
isTraversing_ = false;
}
void UINode::ProcessOffscreenTask(bool recursive)

View File

@ -828,6 +828,7 @@ private:
bool isBuildByJS_ = false;
bool isRootBuilderNode_ = false;
bool isArkTsFrameNode_ = false;
bool isTraversing_ = false;
NodeStatus nodeStatus_ = NodeStatus::NORMAL_NODE;
RootNodeType rootNodeType_ = RootNodeType::PAGE_ETS_TAG;
RefPtr<ExportTextureInfo> exportTextureInfo_;