!44024 【RichEditor】修复Crash问题

Merge pull request !44024 from FreemanBao/cherry-pick-1726815241
This commit is contained in:
openharmony_ci 2024-09-21 16:29:20 +00:00 committed by Gitee
commit 1ee232942a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -5621,6 +5621,13 @@ int32_t RichEditorPattern::ProcessDeleteNodes(std::list<RichEditorAbstractSpanRe
CHECK_NULL_RETURN(spanItem, eraseLength);
auto text = spanItem->content;
std::wstring textTemp = StringUtils::ToWstring(text);
auto textTempSize = static_cast<int32_t>(textTemp.size());
if (textTempSize < it.OffsetInSpan()) {
TAG_LOGW(AceLogTag::ACE_RICH_TEXT, "ProcessDeleteNodes failed, "
"content = %{private}s, spanItemSize = %{public}d, offsetInSpan = %{public}d",
text.c_str(), textTempSize, it.OffsetInSpan());
continue;
}
textTemp.erase(it.OffsetInSpan(), it.GetEraseLength());
if (textTemp.size() == 0) {
deleteNodes.emplace(it.GetSpanIndex());