Skip to content

Commit

Permalink
fix: a possible crash
Browse files Browse the repository at this point in the history
Signed-off-by: qwq233 <qwq233@qwq2333.top>
  • Loading branch information
qwq233 committed Dec 10, 2023
1 parent 560e554 commit b111b08
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ object StringUtils {
skip += 1
}

// prevent out of bound
entities.forEach {
if (it.offset >= panguText.length) {
it.offset = panguText.length - 1
}
if (it.offset + it.length > panguText.length) {
it.length = panguText.length - it.offset
}
}

return Pair(panguText, entities)
}
}

0 comments on commit b111b08

Please sign in to comment.