Fix when calling parse_hex_char out of bounds
Closes: #158 Changelog-Fixed: Fix crash with @ sign in some posts
This commit is contained in:
committed by
William Casarin
parent
0af8646fd5
commit
205774f684
@@ -97,6 +97,12 @@ func parse_digit(_ p: Parser) -> Int? {
|
||||
func parse_hex_char(_ p: Parser) -> Character? {
|
||||
let ind = p.str.index(p.str.startIndex, offsetBy: p.pos)
|
||||
|
||||
// Check that we're within the bounds of p.str's length
|
||||
if p.pos >= p.str.count {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
if let c = p.str[ind].unicodeScalars.first {
|
||||
// hex chars
|
||||
let d = c.value
|
||||
|
||||
Reference in New Issue
Block a user