Make sure range.location isn't out-of-bounds

Fix for #2512.
This commit is contained in:
Nate Weaver 2020-10-20 12:05:40 -05:00
parent 0f8ffb3e01
commit 643b9f4659
1 changed files with 2 additions and 0 deletions

View File

@ -191,6 +191,8 @@ extension NSAttributedString {
result.addAttribute(.font, value: baseFont, range: NSRange(location: 0, length: result.length))
for (range, styles) in attributeRanges {
if range.location >= result.length { continue }
let currentFont = result.attribute(.font, at: range.location, effectiveRange: nil) as! Font
let currentDescriptor = currentFont.fontDescriptor
var descriptor = currentDescriptor.copy() as! FontDescriptor